Hello,
Our model contains a property which contains the gridmodel. In the model we also get the data (not in the controller) and we set the datasource of the grid and it's layout :
public class DocumentErrorsViewModel
{
public override GridModel GridFiltering { get; set; }
public DocumentErrorsViewModel() { GridFiltering = new Infragistics.Web.Mvc.GridModel(); GridFiltering.DataSource = GetGridData();
GridFiltering.Width = "100%"; GridFiltering.Columns.Add(new GridColumn("Scanner", "ScannerName", "string", "70%")); GridFiltering.Columns.Add(new GridColumn("Scan date time", "ScanTime", "date", "30%"));
...
}
private IQueryable<DocumentErrorGridModel> GetGridData() {
return ...
In our controller we just give back our model, nothing more, nothing less :-)
public class ScanController : Controller {
public ActionResult Index()
{ var model = new ScanErrorsViewModel(); return View(model); }
In our webpage we just add our grid:
@Html.Infragistics().Grid("grid1", Model.GridFiltering)
Everything just works fine, but when we want to refresh the data of our grid (Refresh-button on the webpage) we don't want to refresh our entire webpage but only the datasource of the grid.
I tried to use the DataSourceUrl in the controller to trigger an action:
public ActionResult Index() { var model = new ScanErrorsViewModel(); model.GridFiltering.DataSourceUrl = Url.Action("BindGridFiltering"); return View(model); }
[GridDataSourceAction] [ActionName("BindGridFiltering")] public ActionResult BindGridFiltering() { // Get datasource in model var ds = ... return View("RowSelection", ds); }
But this does not work. I would think that the action will also be triggered when the page will be loaded (so the datasource would be fetched twice), but the action doesn't go off.
Other problem is that I don't know how to access the model from the controller...
Do I have to use another technique or am I missing something ?
Hi,
Have you been able to take a look at the provided sample application? If you have any other questions or concerns about this matter please do not hesitate to contact us.