Hi,
I am binding to a data source that is set in the GridDataSourceAction method as below -
List<Dictionary<string, string>> rows = new List<Dictionary<string, string>>(); Dictionary<string, string> row = null; foreach (DataRow dr in dataTable.Rows) { row = new Dictionary<string, string>(); foreach (DataColumn col in dataTable.Columns) row.Add(col.ColumnName, dr[col] == DBNull.Value ? string.Empty : dr[col].ToString()); rows.Add(row); } return View(rows.AsQueryable());
I have set remote paging and remote filtering in my grid in javascript. The remote paging works successfully however the grid does not filter and the spinner keeps spinning. On closer inspection, i check the response and see that i am getting an error -
"Exception: The grid model doesn't contain a column named: KeyOfColumnImFiltering"
I have checked the data source and can confirm i do the columns present.
Why would this be happening?
Thanks
Hello Hussam,
While looking at your configuration I don't see anything worrying that may cause the error. This makes me think that the problem is something else. Can you provide me with an isolated sample, so that I can run and test it on my side? Please note that it's not necessary to attach the whole database, you may extract some data of it and hardcode it in the sample. The idea is I can see your code that could eventually reproduce the error.
Waiting for your answer.
Hi Tsanna.
This is the entire javascript code that is used -
$(function () { $('#incumbentDataViewGrid').igGrid({ dataSource: '/IncumbentDataView/UpdateIncumbentDataView', autoGenerateLayouts: false, autoGenerateColumns: false, mergeUnboundColumns: false, renderCheckboxes: true, responseDataKey: 'Records', autoCommit: true, primaryKey: "RowIndex", generateCompactJSONResponse: false, features: [ { name: 'Paging', pageIndexUrlKey: 'page', pageSizeUrlKey: 'pageSize', recordCountKey: 'TotalRecordsCount', pageSize: 10, type: 'remote' } , { name: 'Resizing', }, { name: 'Updating', enableAddRow: false, enableDeleteRow: false, columnSettings: [ { columnKey:"Job_Title",editorOptions: { readOnly:true}},{ columnKey:"Vertical",editorOptions: { readOnly:true}},{ columnKey:"Job_Code",editorOptions: { readOnly:true}},{ columnKey:"Firm_Name",editorOptions: { readOnly:true}},{ columnKey:"Actual_Bonus_or_Commissions",editorOptions: { readOnly:true}},{ columnKey:"Restricted_Stocks_Value",editorOptions: { readOnly:true}},{ columnKey:"Stock_Options_Value_FAS_123",editorOptions: { readOnly:true}},{ columnKey:"Performance_LTI",editorOptions: { readOnly:true}},{ columnKey:"Annual_Base_Salary",editorOptions: { readOnly:true}},{ columnKey:"Target_Bonus_as_a_percentage_of_Base_Salary",editorOptions: { readOnly:true}},{ columnKey:"Zip_Code",editorOptions: { readOnly:true}},{ columnKey:"Salary_Grade",editorOptions: { readOnly:true}},{ columnKey:"Business_Unit_Name",editorOptions: { readOnly:true}},{ columnKey:"Include",editorOptions: { readOnly:false}},{ columnKey:"RowIndex",editorOptions: { readOnly:true}} ] }, { name: 'Filtering', type: 'remote'} ], columns: [ { headerText:"Job Title",key:"Job_Title",dataType:"string",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Vertical",key:"Vertical",dataType:"string",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Job Code",key:"Job_Code",dataType:"string",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Firm Name",key:"Firm_Name",dataType:"string",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Actual Bonus or Commissions",key:"Actual_Bonus_or_Commissions",dataType:"number",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Restricted Stocks Value",key:"Restricted_Stocks_Value",dataType:"number",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Stock Options Value FAS 123",key:"Stock_Options_Value_FAS_123",dataType:"number",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Performance LTI",key:"Performance_LTI",dataType:"number",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Annual Base Salary",key:"Annual_Base_Salary",dataType:"number",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Target Bonus as a % of Base Salary",key:"Target_Bonus_as_a_percentage_of_Base_Salary",dataType:"number",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Zip Code",key:"Zip_Code",dataType:"string",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Salary Grade",key:"Salary_Grade",dataType:"string",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Business Unit Name",key:"Business_Unit_Name",dataType:"string",allowHiding: true,hidden:false,readOnly:true},{ headerText:"Include In Data",key:"Include",dataType:"bool",allowHiding: true,hidden:false,readOnly:false},{ headerText:"Row Index",key:"RowIndex",dataType:"string",allowHiding: true,hidden:true,readOnly:true} ] }); });
The columns that you see there are generated from the datatable itself. I create a collection of this type of string
string columnQuery = "{ headerText:\""+headerText + "\",key:\"" + key + "\",dataType:\"" + dataType + "\",allowHiding: true,hidden:" + hidden+ ",readOnly:" + readOnly+ "}";
key and header text and datatype are determined via the reading of the data columns. This string is added to a collection of string and then passed to a model which renders it into the view. This is my view code before run time:
$(function () { $('#incumbentDataViewGrid').igGrid({ dataSource: '/IncumbentDataView/UpdateIncumbentDataView', autoGenerateLayouts: false, autoGenerateColumns: false, mergeUnboundColumns: false, renderCheckboxes: true, responseDataKey: 'Records', autoCommit: true, primaryKey: "RowIndex", generateCompactJSONResponse: false, features: [ { name: 'Paging', pageIndexUrlKey: 'page', pageSizeUrlKey: 'pageSize', recordCountKey: 'TotalRecordsCount', pageSize: 10, type: 'remote' } , { name: 'Resizing', }, { name: 'Updating', enableAddRow: false, enableDeleteRow: false, columnSettings: [ @Html.Raw(Model.ColumnSettingsQuery) ] }, { name: 'Filtering', type: 'remote'} ], columns: [ @Html.Raw(Model.IncumbentDataViewQuery) ] }); });
I do not have a collection of grid columns.
Thanks,
Hussam
Can you provide me with the grid initialization code and especially with the columns collection definition? Please make sure that there are no duplicate column keys and non defined columns in the grid columns collection.