سؤال

I am using a webgrid to display some dynamic data. I have recently refactored my code, to move away from a hierarchal Model, containing various different types of data to be displayed in a View to using ViewBag.

Previously the grid would sort the columns fine, just be clicking on the header, however since I changed to ViewBag, my table does not sort. My new code is as follows:

@if (ViewBag.data != null)
{
var grid = new WebGrid(
    source: ViewBag.data,
    defaultSort: "StudyName",
    rowsPerPage: 10,
    canSort: true,
    canPage: true,
    ajaxUpdateContainerId: "tableDiv"
    ); 

@grid.GetHtml(
tableStyle: "resultTable",
columns: grid.Columns(
    ViewBag.columns)
)
}

Anybody any ideas?

Thanks.

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top