I was wondering which one is recommended to use ? What are the pros & cons ?
if DataSourceUrl is the better option, can you help me on how do I pass parameter to an MVC ActionMethod that I set as the DataSourceUrl?
Thanks,
Jeffrey
Hi Jeffrey,
jAndika said:I was wondering which one is recommended to use ? What are the pros & cons ?
Simply speaking DataSource is used in a local data binding and DataSourceUrl is used in remote data binding scenarios.They are designed to solve different use cases so it depends on your requirements. If you want remote Paging, Sorting or Filtering you should use DataSourceUrl. This is the better choice if you have large data set. The data will be loaded and extracted on demand.If you have small data set then you can use DataSource. This way the data will be downloaded on the client and all Paging, Sorting, Filtering operations will be done on the client.You should read Developing ASP.NET MVC Applications with igGrid topic in order to get better understanding of these options. Look at the Data Binding section where these two options are described in greater detail.
jAndika said:if DataSourceUrl is the better option, can you help me on how do I pass parameter to an MVC ActionMethod that I set as the DataSourceUrl?
You can use $.ig.DataSource.options.urlParamsEncoded option. Here is a sample code:
$("#grid").data("igGrid").dataSource.settings.urlParamsEncoded = function (owner, params) { params.filteringParams.$filter = params.filteringParams.$filter + "place your params here"; };
$("#grid").data("igGrid").dataSource.settings.urlParamsEncoded = function (owner, params) {
params.filteringParams.$filter = params.filteringParams.$filter + "place your params here";
};
Hope this helps,Martin PavlovInfragistics, Inc.
Thanks for the explanation. Tried the urlParamsEncoded but couldn't make it to work. What works for me is changing the dataSourceObject of the grid like so during runtime:
$('#btnSearch').click(function (event) {
var url = 'GetData';
//grab all search inputs value var desc = $('#txtDesc').attr('value');
var params = (desc && 'Description=' + desc + '&');
if (params) { url += '?' + params; url = url.slice(0, -1); // remove leading ampersand } $('#gridMatrix').igGrid('dataSourceObject', url); $('#gridMatrix').igGrid('dataBind');});
Thanks