1

I have a jQGrid, where in the rowId<tr id=''> is set as blank. I want the rowNum to be set as the id of the tr Please let me know what I am missing in this. My Code is :

        var strFieldNames = new Array('Order ID', 'Debt Type', 'Member Name', 'Welfare Status', 'Accrual Effective Date', 'Obligation Accrued', 'Interest Period', 'Interest Accrued');
        var strFieldValues = new Array('orderId', 'debtType', 'name', 'currentWelfareStatus', 'accrualEffDt', 'oblAccrued', 'interestPeriod','interestAccrued');
        $('#grid0').jqGrid('GridUnload');
        selectedDynaListNum=0
        $("#grid0").jqGrid({
         datatype: "local",
        data: getMyResponseObj(),

        colNames:[strFieldNames[0], strFieldNames[1], strFieldNames[2], strFieldNames[3], strFieldNames[4], strFieldNames[5], strFieldNames[6], strFieldNames[7]],
        colMandReq:['-1','-1','-1','-1','-1','-1','-1','-1'],
        colModel:[ 

            {name:strFieldValues[0], index:strFieldValues[0], editable:false, readonly:true, width:100,
                    hidden:false,sortable:false}, 

            {name:strFieldValues[1], index:strFieldValues[1], editable:false, readonly:true, width:100,
                    hidden:false,sortable:false}, 

            {name:strFieldValues[2], index:strFieldValues[2], editable:false, readonly:true, width:90,
                    hidden:false,sortable:false}, 

            {name:strFieldValues[3], index:strFieldValues[3], editable:false, readonly:true, width:90,
                    hidden:false,sortable:false}, 

            {name:strFieldValues[4], index:strFieldValues[4], editable:false, readonly:true, width:100,
                    hidden:false,sortable:false}, 

            {name:strFieldValues[5], index:strFieldValues[5], editable:false, readonly:true, width:100,
                    hidden:false,sortable:false}, 

            {name:strFieldValues[6], index:strFieldValues[6], editable:false, readonly:true, width:100,
                    hidden:false,sortable:false}, 

            {name:strFieldValues[7], index:strFieldValues[7], editable:false, readonly:true, width:100,
                    hidden:false,sortable:false},
        ],

           loadComplete: function() 
                    {

                        jQuery('.ui-jqgrid-hbox').removeClass('ui-jqgrid-hbox').addClass('ui-jqgrid');
                        var grid0 = jQuery("#grid0");
                        var allDropDownElements = getAllDropDownElements0(); 
                        var allDropDownElementRefTables = getAllDropDownElementRefTables0();
                        processAjaxDynaTableFromReferenceTable(grid0, allDropDownElements, allDropDownElementRefTables, 0, getMyResponseObj(), refTableDataJSON);

                    },
                gridComplete:function() 
                {
                },
                   onSelectRow: function(id) 
                   {

                        },

                pager: '#pager0',
                 rowList: [6,10,20,40,60,80,100],
                gridview: true,
                rownumbers: false,
                autoencode: true,
                shrinkToFit: true,
                autowidth: true,
                sortable: false,
                height: '100%',
                rowNum: 100,
                caption:""

                });
Sashi Kant
  • 13,277
  • 9
  • 44
  • 71
  • this should be working, i don't see any issues but need to ask is this code working? Do you get data here `data: getMyResponseObj(),`? – Jai Jul 21 '14 at 09:33
  • @Jai: Yes the data is getting populated, but the Id of every tr is blank – Sashi Kant Jul 21 '14 at 09:35
  • I don't think this might have any issue like that, are you sure anyother code is not replacing each tr's id with blank values? – Jai Jul 21 '14 at 09:41
  • See this fiddle: http://jsfiddle.net/GqaZH/ – Jai Jul 21 '14 at 09:55
  • @Jai: Appreciate your effort. I think I have got the issue, while converting the bean to a json object, there is a field Id which is set as blank. You can answer the fiddle, I will accept your answer Thanks once again :) – Sashi Kant Jul 21 '14 at 10:20
  • @SashiKant: If the grid have column which have **unique** values which can be used as rowid (`id` of `` elements) then you should add `key: true` to the definition of the column (`orderId` column in your case). Additionally I recommend you 1) remove all `index` properties from `colModel` 2) remove properties having **default** values (`editable:false, hidden:false, sortable:false`) and unknown values (`readonly:true`). 3) If you want to change default value for some property (`width` having 150 value as default) you can use `cmTemplate: {width: 100}`. It will reduce `colModel` additionally – Oleg Jul 21 '14 at 10:43
  • @SashiKant: See [the old answer](http://stackoverflow.com/a/6047856/315935) for example which describe what is column templates and how one can use templates to reduce the code of jqGrid and to make it more readable and reliable. Another problem: the line `jQuery('.ui-jqgrid-hbox').removeClass('ui-jqgrid-hbox').addClass('ui-jqgrid');` seems me **very suspected**. Such changes can break internal structure of jqGrid and many CSS rules. Another problem one should never use `var strFieldValues = new Array('orderId',...);`. Instead of that `var strFieldValues = ['orderId',...];` is *always* better. – Oleg Jul 21 '14 at 10:45

1 Answers1

1

The issue was, the jsonObject in the jsonArray which was provided to the jQgrid, was having a column rowId , whose value was 0.

So this was the reason of the issue mentioned above

Sashi Kant
  • 13,277
  • 9
  • 44
  • 71