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

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -