asp.net mvc - Add new column in WebGrid MVC -


in razor view, have collection of objects want display in grid. able fields when want remove , add more out of source (the collection) 'column "daysleft" not exist'

my code:

@code

viewdata("title") = "index"  dim grid = new webgrid(source:=model, defaultsort:="proj_created_time")   dim listofcolumns list(of webgridcolumn) = new list(of webgridcolumn) dim projecttitle webgridcolumn = grid.column("project_title") projecttitle.header = "title" dim projectstatus webgridcolumn = grid.column("proj_status") projectstatus.header = "status" dim projectinitialdate webgridcolumn = grid.column("proj_initial_duedate") projectinitialdate.header = "starting date" dim projectnewduedate webgridcolumn = grid.column("proj_new_duedate") projectnewduedate.header = "due date"  dim daysleftcol new webgridcolumn {.columnname = "daysleft", .header = "daysleft"}  listofcolumns.add(projecttitle) listofcolumns.add(projectstatus) listofcolumns.add(projectinitialdate) listofcolumns.add(projectnewduedate) listofcolumns.add(daysleftcol) 

end code


@grid.gethtml(columns:=listofcolumns, tablestyle:="table") 

any thoughts?

the solution similar this

        dim projectdownload webgridcolumn = grid.column(header:="attachement", columnname:="project_id", format:=function(item)                                                                                                                         if item.project_attachement.count > 0                                                                                                                              dim newlink htmlstring                                                                                                                             each down in item.project_attachement                                                                                                                                 dim chec = down.project_id & " " & down.project_atta_name                                                                                                                                 newlink = new htmlstring(helper.actionlink("download", "filedownload", "project", new {.id = down.project_id, .name = down.project_atta_name}).tostring)                                                                                                                                 return newlink                                                                                                                             next                                                                                                                          else                                                                                                                             return "no file"                                                                                                                         end if                                                                                                                     end function, cansort:=false) 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -