JqGrid problem with striping and frozen columns - jqgrid
I load the grid with striping and frozen columns. Loads correctly. The first line is white, the second line is gray.
When executing the sort on one of the columns, the frozen side starts in gray and the other side starts in white.
Version 4.15.6-free
How to adjust the colors?enter image description here
.myAltRowClass {
background: #E0E0E0;
}
jqTreeGrid - Test zebra
listaData=[
{"termId":51843,"module":"M","option":"W","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["D","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52192,"module":"M","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52338,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52339,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52341,"module":"B","option":"S","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52342,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52343,"module":"B","option":"D","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52344,"module":"B","option":"D","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52345,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxxs","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52346,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52347,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52348,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52349,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":52340,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
{"termId":51848,"module":"B","option":"B","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1","quantityFrozenFields":0,"languagesTerms":["B","B","x","y","z","w"],"languagesTips":["B","","","","",""]},
{"termId":51841,"module":"B","option":"S","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01","quantityFrozenFields":0,"languagesTerms":["P","S","","","",""],"languagesTips":["P","","","","",""]},
{"termId":51842,"module":"B","option":"A","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01","quantityFrozenFields":0,"languagesTerms":["S","A","","","",""],"languagesTips":["U","","","","",""]},
{"termId":52011,"module":"B","option":"U","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01.01","quantityFrozenFields":0,"languagesTerms":["U","U","","","",""],"languagesTips":["","","","","",""]},
{"termId":51844,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01.02","quantityFrozenFields":0,"languagesTerms":["P","Ps","","","",""],"languagesTips":["P","","","","",""]}];
var colModel = [{ label:'Module', name: 'module', width: 160, frozen: true},
{ label:'Option', name: 'option', width: 160, frozen: true},
{ label:'Description', name: 'termDescription', width: 160, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, frozen: true},
{ label:'Strucuture', name: 'menuStructure', width: 80},
{ label: 'termId', name: 'termId', width: 10, hidden: true },
{ label:'Pt', name: 'languagesTerms.0', width:100, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, editable: false},
{ label:'Pt', name: 'languagesTips.0', width:150, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, editable: false, hidden: true},
{ label:'En', name: 'languagesTerms.1', width:100, editable: false},
{ label:'En', name: 'languagesTips.1', width:150, editable: false, hidden: true},
{ label:'Tu', name: 'languagesTerms.2', width:100, editable: false},
{ label:'Tu', name: 'languagesTips.2', width:150, editable: false, hidden: true},
{ label:'Cn', name: 'languagesTerms.3', width:100, editable: false},
{ label:'Cn', name: 'languagesTips.3', width:150, editable: false, hidden: true},
{ label:'Al', name: 'languagesTerms.4', width:100, editable: false},
{ label:'Al', name: 'languagesTips.4', width:150, editable: false, hidden: true},
{ label:'Ce', name: 'languagesTerms.5', width:100, editable: false},
{ label:'Ce', name: 'languagesTips.5', width:150, editable: false, hidden: true}];
var lastSelection ;
jQuery(document).ready(function($) {
jQuery('#jqGrid').jqGrid({
datatype: "local",
data: listaData,
height: 300,
width : 900,
colModel:colModel,
loadonce: true,
shrinkToFit: false,
rowNum: 500,
scroll: 0,
multiSort: false,
loadComplete: function() {
$("tr.jqgrow:odd").addClass('myAltRowClass');
}
});
$("#jqGrid").jqGrid("setFrozenColumns");
});
Thanks
You maybe need to read the docs and search this forum. This functionality is build in in jqGrid (hope in free-jqGrid it is not depreciated).You will need just to use the grid option altRows and use option altclass to use your own class.
You problem is in using two features at the same time - loadComplete and FrozenColumns.
Related
TypeError: Unable to read "stype" of Undefined or Null reference in JQGrid
I want filter on the data which comes dynamically in list format. If i used SearchOptions event for that then it throws error of TypeError: Unable to read "stype" of Undefined or Null reference. Anyone can provide me solution for that. Grid model shown in below: jQuery("#list2").jqGrid({ url: '/LocaleRate/LocaleRates', datatype: "json", colModel: [ { name: 'Id', hidden: true }, { name: 'SourceLocaleId', index: 'SourceLocaleName', width: 130, align: "left", editable: true, edittype: "select", formatter: 'select', editoptions: { value: LocaleList }, editrules: { required: true , stype: 'select', searchoptions: { sopt: ['eq', 'ne'], value: LocaleList }, { name: 'LocaleId', index: 'LocaleName', width: 90, align: "left", editable: true, edittype: "select", formatter: 'select', editoptions: { value: LocaleList }, editrules: { required: true }, stype: "select", searchoptions: { value: LocaleList } }, { name: 'CompanyId', index: 'CompanyName', editable: true, width: 100, editable: true, edittype: "select", formatter: 'select', editoptions: {value: CompanyList}, editrules: { required: true}, stype: "select", searchoptions: { value: CompanyList } }, { name: 'VDBID', id: 'VDBID', editable: true, width: 90, editrules: { required: true }, editoptions: { readonly: "readonly" } }, { name: 'CurrencyId', index: 'CurrencyName', width: 100, editable: true, edittype: "select", formatter: 'select', editoptions: { value: CurrencyList }, editrules: { required: true }, stype: "select", searchoptions: { value: CurrencyList } }, { name: 'HourRate', id: 'HourRate', editable: true, width: 130, editrules: { required: true } }, { name: 'PageRate', id: 'PageRate', editable: true, width: 90, editrules: { required: true } }, { name: 'WordRateExact', id: 'WordRateExact', editable: true, width: 130, editrules: { required: true } }, { name: 'WordRateDuplicate', id: 'WordRateDuplicate', editable: true, width: 140, editrules: { required: true } }, { name: 'WordRateFuzzy', id: 'WordRateFuzzy', editable: true, width: 130, editrules: { required: true } }, { name: 'WordRateNew', id: 'WordRateNew', editable: true, width: 90, editrules: { required: true } }, { name: 'MinimumPageCount', id: 'MinimumPageCount', editable: true, width: 130, editrules: { required: true } }, { name: 'MinimumWordCount', id: 'MinimumWordCount', editable: true, width: 130, editrules: { required: true } }, { name: 'WordRateExactComplex', id: 'WordRateExactComplex', editable: true, width: 150, editrules: { required: true } }, { name: 'MinimumCharge', id: 'MinimumCharge', editable: true, width: 90, editrules: { required: true } }, { name: 'WordRateDuplicateComplex', id: 'WordRateDuplicateComplex', editable: true, width: 150, editrules: { required: true } }, { name: 'WordRateFuzzyComplex', id: 'WordRateFuzzyComplex', editable: true, width: 90, editrules: { required: true } }, { name: 'WordRateNewComplex', id: 'WordRateNewComplex', editable: true, width: 90, editrules: { required: true } }, { name: 'FirstProofRate', id: 'FirstProofRate', editable: true, width: 90, editrules: { required: true } }, { name: 'WordRateHighFuzzy', id: 'WordRateHighFuzzy', editable: true, width: 90, editrules: { required: true } }, { name: 'WordRateHighFuzzyComplex', id: 'WordRateHighFuzzyComplex', editable: true, width: 90, editrules: { required: true } }, { name: 'DTPVendorHourRate', id: 'DTPVendorHourRate', editable: true, width: 90, editrules: { required: true } }, { name: 'DTPVendorPageRate', id: 'DTPVendorPageRate', editable: true, width: 90, editrules: { required: true } }, { name: 'VDBPriceLineID', id: 'VDBPriceLineID', editable: true, width: 90, editrules: { required: true } }, { name: 'MTRate', id: 'MTRate', editable: true, width: 90, editrules: { required: true } }, { name: 'DTPClientHourRate', id: 'DTPClientHourRate', editable: true, width: 90, editrules: { required: true } }, { name: 'IsActive', editable: true, width: 40, edittype: "checkbox", editoptions: { value: "True:False" } } ], rowNum: 10, rowList: [10, 20, 30], pager: '#pager', loadonce: true, sortname: 'id', height: "auto", width: 2000, viewrecords: true, sortorder: "desc", caption: "JSON Example", jsonReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, id: "0" }, autowidth: true, }); jQuery("#list2").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, }); With Reference to above code, I want filters on SourceLocaleId, LocaleID, CompanyId & CurrencyId fields which has dynamic data.
Here I have replaced index value of each column which has dynamic data in list manner from 'SourceLocaleName' to 'SourceLocaleId'.
Set column to show 0 in JqGrid
I have a jqGrid. my function is -- $("#grid").jqGrid({ url: "/Log/GetLogs", datatype: 'json', mtype: 'Get', colNames: ['LogID', 'Agency Billing Code', 'License Number', 'Equipement Number', 'Year', 'Make', 'Model', 'Color', 'Begin Miles', 'End Miles'], colModel: [ { key: true, hidden: true, name: 'ID', index: 'ID' }, { key: false, name: 'Year', index: 'Year', editable: false }, { key: false, name: 'Make', index: 'Make', editable: false }, { key: false, name: 'Model', index: 'Model', editable: false }, { key: false, name: 'Color', index: 'Color', editable: false }, { key: false, name: 'Miles', index: 'Miles', editable: true, cellvalue: "" }, ], pager: jQuery('#pager'), rowNum: 10, rowList: [10, 20, 30, 40], height: '100%', viewrecords: true, caption: 'Log List', emptyrecords: 'No Records', jsonReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, id: "0" }, autowidth: true, multiselect: false }); When the grid loads, database is returning the value of "Miles" but I don't want to show that. I just want to show 0, and when I edit the miles values it should map to Miles in my object. Please let me know how can I achieve that? Thanks..
To accomplish what you need you need to have a formatter and unformatter for the miles column. You have not specified on how you will be editing the grid row(Inline, form Edit, custom...etc) but I created inline edit as an example for you. Here is a the complete solution in jsfiddle if you want to play with it. for editing just click the row and the miles will show its original value when on edit but show 0 on non edit mode. For more details on how formatting works see Here var mileformatter= function (cellval, options, rowObject) { return "<span data-val='"+cellval+"'>0</span>"; } var mileUnFormat= function (cellvalue, options, cell) { return $('span', cell).attr('data-val'); } "use strict"; var mydata = [ {ID:"1", Year: "1933", Make: "Nissan",Model:"Model1", Color: "White",Miles:1222}, {ID:"2", Year: "2008", Make: "Toyota",Model:"Model2" , Color: "Gray",Miles:3000}, ]; $("#list").jqGrid({ data: mydata, datatype: "local", mtype: 'Get', colModel: [ { key: true, hidden: true, name: 'ID', index: 'ID' }, { key: false, name: 'Year', index: 'Year', editable: false }, { key: false, name: 'Make', index: 'Make', editable: false }, { key: false, name: 'Model', index: 'Model', editable: false }, { key: false, name: 'Color', index: 'Color', editable: false }, { key: false, formatter:mileformatter,unformat:mileUnFormat, name: 'Miles', index: 'Miles', editable: true, cellvalue: "" }, ], pager: jQuery('#pager'), rowNum: 10, rowList: [10, 20, 30, 40], height: '100%', viewrecords: true, caption: 'Log List', emptyrecords: 'No Records', jsonReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, id: "0" }, autowidth: true, multiselect: false, onSelectRow: function (id) { jQuery('#list').editRow(id, true); } }); Here is an edited answer for what you are looking for and a new jsfiddle link to play with Note that I removed the unformatter and also added beforeSaveRow function. var onEdit=false; var mileformatter= function (cellval, options, rowObject) { if(onEdit==true) { return cellval; onEdit=false; } return 0; } "use strict"; var mydata = [ {ID:"1", Year: "1933", Make: "Nissan",Model:"Model1", Color: "White",Miles:1222}, {ID:"2", Year: "2008", Make: "Toyota",Model:"Model2" , Color: "Gray",Miles:3000}, ]; $("#list").jqGrid({ data: mydata, datatype: "local", mtype: 'Get', colModel: [ { key: true, hidden: true, name: 'ID', index: 'ID' }, { key: false, name: 'Year', index: 'Year', editable: false }, { key: false, name: 'Make', index: 'Make', editable: false }, { key: false, name: 'Model', index: 'Model', editable: false }, { key: false, name: 'Color', index: 'Color', editable: false }, { key: false, formatter:mileformatter, name: 'Miles', index: 'Miles', editable: true, cellvalue: "" }, ], pager: jQuery('#pager'), rowNum: 10, rowList: [10, 20, 30, 40], height: '100%', viewrecords: true, caption: 'Log List', emptyrecords: 'No Records', jsonReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, id: "0" }, autowidth: true, multiselect: false, onSelectRow: function (id) { jQuery('#list').editRow(id, { "keys": true, oneditfunc: function () { }, "successfunc": function () { alert('successfunc'); }, "url": null, "extraparam": {}, "aftersavefunc": function () { alert('aftersavefunc'); }, "errorfunc": null, "afterrestorefunc": null, "restoreAfterError": true, "beforeSaveRow": function (options, rowid) { onEdit=true; jQuery("#list").saveRow(id, false); return false; } }); } }); You can customize the SaveRow as follows and put the post url of your own. saveparameters = { "successfunc" : null, "url" : "yoururl", "extraparam" : {}, "aftersavefunc" : null, "errorfunc": null, "afterrestorefunc" : null, "restoreAfterError" : true, "mtype" : "POST" } jQuery("#grid_id").jqGrid('saveRow',rowid, saveparameters);
NO URL IS SET - error in jqGrid (Add, Delete dialog)
I've following Grid to display data, now when I want to add new record it gives the error 'NO URL IS SET' $(document).ready(function () { $('#PRGrid').jqGrid({ //url from wich data should be requested url: '#Url.Action("BindData")?FillType=' + getFillType(), //event for inline edit onSelectRow: function (currentSelectedRow) { if (currentSelectedRow && currentSelectedRow != $.lastSelectedRow) { //save changes in row $('#PRGrid').jqGrid('saveRow', $.lastSelectedRow, false); $.lastSelectedRow = currentSelectedRow; } //trigger inline edit for row }, //type of data datatype: 'json', //url access method type mtype: 'POST', //columns names colNames: ['Code', 'Name', 'No_Rooms', 'Dept_Code', 'Total_Items'], //columns model colModel: [ { name: 'Code', index: 'Code', align: 'left', width: '120px', editable: true, edittype: 'select', editoptions: { maxlength: 25, dataUrl: '#Url.Action("GetRooms")', dataEvents: [{ type: 'change', fn: function (e) { var ret = $.ajax({ url: '#Url.Action("selectRoom")?id=' + $(this).val(), async: false, success: function (ret) { $('#Name').val(ret.Name); $('#No_Rooms').val(ret.qty); $('#Dept_Code').val(ret.DeptCode); $('#Total_Items').val(ret.Total_Items);} });} }] }}, { name: 'Name', index: 'Name', align: 'left', formatter: "text", width: '185px', editable: true, editrules: { required: true }, editoptions: { readonly: 'readonly'} }, { name: 'No_Rooms', index: 'No_Rooms', align: 'left', formatter: "text", width: '102px', integer: true, editable: true, editrules: { required: true }, editoptions: { readonly: 'readonly'} }, { name: 'Dept_Code', index: 'Dept_Code', align: 'left', formatter: "text", width: '78px', editable: true, editrules: { required: true }, editoptions: { readonly: 'readonly'} }, { name: 'Total_Items', index: 'Total_Items', align: 'left', formatter: "text", width: '82px', integer: true, editable: true, editrules: { required: true }, editoptions: { readonly: 'readonly'} }, ], //pager for grid pager: $('#PRGridPager'), //number of rows per page rowNum: 5, //initial sorting column sortname: 'Code', //initial sorting direction sortorder: 'asc', recreateForm:true, //we want to display total records count viewrecords: true, //grid height height: '100%' }); $('#PRGrid').jqGrid('navGrid', '#PRGridPager', { add: true, del: true, edit:false, search: true }, {width: '330', url:'#Url.Action("InsertPRGridRecord")', closeAfterAdd: true }, {width: '330', url:'#Url.Action("DeleteGridRecord")'}); var dialogPosition = $(this).offset(); Problem arrise when I want to add or delete the record from the grid, Here I've defined both the methods InsertPRGridRecord() and DeleteGridRecord(), but it gives the same error 'NO URL IS SET' at the time of submitting the data on Add Record or Delete Record dialog.
I think the problem exist because you use incorrect the parameters of navGrid. Your current code uses '#Url.Action("DeleteGridRecord")' as URL of "Add" and '#Url.Action("InsertPRGridRecord")' as URL of "Edit". The URL of "Delete" is not specified.
How to properly set the jsonReader of a jqGrid to handle string array of rows
Here are my column and model items: var col_names = ['Qty', 'SFC', 'Item Nbr', 'Brand', 'Product', 'Supplier', 'Price', 'UOM', 'Case', 'Remarks', 'Weight', 'Par', 'Sort', 'Purchased', 'ProductId']; var col_model = [ { name: 'Quantity', index: 'Quantity', width: 22, sorttype: "number", editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 15} }, { name: 'ProductAttributes', index: 'ProductAttributes', width: 50 }, { name: 'ItemNum', index: 'ItemNum', width: 50, align: "right"}, { name: 'BrandName', index: 'BrandName', width: 100 }, { name: 'ProducName', index: 'ProducName', width: 150 }, { name: 'SupplierName', index: 'SupplierName', width: 100 }, { name: 'Price', index: 'Price', width: 40, sorttype: "number", align: "right" }, { name: 'UOM', index: 'UOM', width: 30 }, { name: 'CasePack', index: 'CasePack', width: 30 }, { name: 'PackageRemarks', index: 'PackageRemarks', width: 80 }, { name: 'AveWeight', index: 'AveWeight', width: 33, align: "right" }, { name: 'Par', index: 'Par', width: 20, align: "right", editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 15} }, { name: 'SortPriority', index: 'SortPriority', hidden: true }, { name: 'LastPurchaseDate', index: 'LastPurchaseDate', width: 50, align: "right" }, { name: 'ProductId', index: 'ProductId', hidden: true, key: true }, ]; here's the grid initialization favoriteGrid = $('#favoriteGrid'); favoriteGrid.jqGrid({ url: '/xxx/yyy/zzz/', datatype: 'json', ajaxGridOptions: { contentType: "application/json" }, jsonReader: { id: "ProductId", cell: "", root: function (obj) { return obj.rows; }, page: function () { return 1; }, total: function () { return 1; }, records: function (obj) { return obj.rows.length; }, repeatitems: false }, colNames: col_names, colModel: col_model, pager: $('#favoritePager'), pginput: false, rowNum: 1000, autowidth: true, sortable: true, // enable column sorting multiselect: true, // enable multiselct gridview: true, ignoreCase: true, loadonce: true, // one ajax call per loadui: 'block', loadComplete: function () { fixGridHeight(favoriteGrid); }, ondblClickRow: function (rowid, ri, ci) { }, onSelectRow: function (id) { if (id && id !== lastSel) { favoriteGrid.restoreRow(lastSel); lastSel = id; } favoriteGrid.editRow(id, true); }, gridComplete: function () { } }).jqGrid('navGrid', '#favoritePager', { add: false, edit: false, del: false, search: true, refresh: false }, {}, {}, {}, { multipleSearch: true, showQuery: false }, {}).jqGrid('sortableRows').jqGrid('gridDnD'); and finally, the data: {"rows":[["1",null,"342240"," ","15 AMP, 600V, TIME DELAY, CLASS G","Home Depot - Canada","3.83","EA","1","- 15A, 600V - Class G - Mfg #SC-15","0.02","","0",null,"2977175133"],["1",null,"3573375","NEWPRT","STEAK TOP SIRLOIN CH CC 8OZ","SYSCO","6.875","LB","24 PK","8 OZ","24 LB","","0",null,"1675949601"],["1",null,"201805"," ","GE-HOTPOINT DISHWASHER UPPER RACK","Home Depot - Canada","54.43","EA","1","Dishwasher Upper Rack - Fits Models #HDA2000, HDA2100 And GSD2100 - Mfg #WD28X10011","6.5","","0",null,"2977172115"],["1",null,"286044"," ","GE DISHWASHER SILVERWARE BASKET","Home Depot - Canada","19.19","EA","1","Silverware Basket - Mfg #WD28X265","0.06","","0",null,"2977172688"]]} I get the right number of rows and the columns but no data is displayed in the grid, if that makes sense. Just for completeness: [HandleJsonException] public JsonResult ProductGroupService(Int64 id = 0) { var q = Repository.GetFavoriteProducts(SimpleSessionPersister.User.Id, id).ToArray(); var result = (from fp in q select new string[] { Convert.ToString(fp.Quantity), fp.ProductAttributes, fp.ItemNum, fp.BrandName, fp.ProducName, fp.SupplierName, Convert.ToString(fp.Price), fp.UOM, fp.CasePack, fp.PackageRemarks, fp.AveWeight, Convert.ToString(fp.Par), Convert.ToString(fp.SortPriority), fp.LastPurchaseDate, Convert.ToString(fp.ProductId) }).ToArray(); var jsonData = new { rows = result }; return Json(jsonData, JsonRequestBehavior.AllowGet); } Thank you, Stephen
You main problem is that you used repeatitems: false property of the jsonReader which is wrong for your input. Moreover you should remove trailing comma at the end of definition of col_model. The error will be ignored by many modern browsers, but not for the old one. After the changed the grid will be successfully loaded: see the demo.
Column editable show different in Add/Edit Model Popup. How?
Structure of my grid columns. Now problem is that I want CompanyName only editable and sown in Edit ModelPopup and for adding ModelPopup I want all the below to be shown in popup. How do I do that? colModel: [ { name: 'companyID', index: 'companyID', width: 60, editable: false, editoptions: { readonly: true } }, { name: 'companyName', index: 'companyName', width: 190, editable: true, editrules: { required: true} }, { name: 'companyCity', index: 'companyCity', width: 190, editable: true, editrules: { required: true} }, { name: 'companyState', index: 'companyState', width: 50, sortable: false, align: 'center', editable: true, editrules: { required: true} }, { name: 'action', index: 'action', width: 80, sortable: false, align: 'center', editable: false, } ] ... .navGrid('#pager10', { view:true, edit: true, add: true, del: true }
The most simple way to do this is to use beforeShowForm method. See my old answer on the same subject here. In case of inline editing instead of form editing you can follow another suggestion from here.