1

I have a jqgrid code as follows. I wanted to add a custom property to the colmodel same as myproperty in the code below.

...
jQuery("#list2").jqGrid({
    url:'myurl',
    datatype: "json",
    colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
    colModel:[
        {name:'id',index:'id', width:55},
        {name:'invdate',index:'invdate', width:90, myproperty:{prop1:'true', prop2:1}},
        {name:'name',index:'name asc, invdate', width:100, myproperty:{prop1:'false', prop2:2}},
        {name:'amount',index:'amount', width:80, align:"right"},
        {name:'tax',index:'tax', width:80, align:"right"},      
        {name:'total',index:'total', width:80,align:"right"},       
        {name:'note',index:'note', width:150, sortable:false}       
    ],
    rowNum:10,
    rowList:[10,20,30],
    pager: '#pager2',
    sortname: 'id',
    viewrecords: true,
    sortorder: "desc",
    caption:"JSON Example"
});
jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false});

The need for this is because I want to pass some properties to each column and get it later as follows. Lets say I want myproperty for row 1. I would do that

var rowId=1
var colmodel= jQuery("#list2").jqGrid('getGridParam', 'colModel');
var myProperty = colmodel[rowid].myproperty; 
Helen Araya
  • 1,886
  • 3
  • 28
  • 54
  • It sounds that you need to set **individual values of the properties for every row of the grid**. `myproperty` in `colModel` can be used only to set **the same values for every row in the column**. Look at [the answer](http://stackoverflow.com/a/18313154/315935) which shows one way of setting individual information. The most important would be *where is the origin of such information*. I suppose that the returned data from `myurl` contains already the data. In the case there are much more ways. It's depend on which version and which fork of jqGrid you use. Could you include more details? – Oleg Dec 28 '15 at 23:43
  • Oleg my grid is going to be generated dynamically in javascript I get the column model and its properties(including myproperty) from a database. Hence myproperty is not in my myurl. Basically what I wanted to do is to set unobtrusive validation jqgrid for inline edit. I wanted myproperty to hold the custom validation types(lets say "positiveinteger","money"..etc then I would want to write my edit html in editoptions custom_element callback based on the myproperty values. – Helen Araya Dec 29 '15 at 15:10

0 Answers0