Custom search with SearchModel...

Sep 27, 2011 at 6:41 PM

Hello...

I added a div above my grid, like that :

<div id="filter-grid"></div>
 
So, I added that javascript to enable JQGrid search on that div :
 $('#filter-grid').filterGrid('#grid', {
        buttonclass: 'width-6',
        gridModel: false,
        buttonclass: 'width-6',
        enableSearch: 'false',
        filterModel: [{
            label: '',
            name: 'search',
            stype: 'text'
        }]
  });
It works fine using that Controller method:
public ActionResult List(int page, int rows, string sidx, string sord, string search)
But I´d like to know how integrate that with SearchModel parameter... Is it possible?
Thanks
Sep 28, 2011 at 3:37 AM

Follow is my code. 

public ActionResult List(SearchModel searchModel)
        {
            var ctx = new NorthwindDataContext();

            var q = ctx.Products;

            var data = q.ToGridData(searchModel, GridModel.ProductColumns);

            return Json(data, JsonRequestBehavior.AllowGet);
        }

Use the Method ToGridData which the controls provided.