user801116
user801116

Reputation:

How to add row in jqGrid, that also has a checkbox

I am adding to my jqgrid with below code all except cfgname and updateDate gets displayed into my grid, what is the problem here?

function addRow(cfgid,cfgname,hostname,cfgDesc,productId,cfgType,updateDate,emailAddress,absolutePath)
{
console.info(cfgid+", "+cfgname+", "+hostname+", "+cfgDesc+", "+productId+", "+cfgType+", "+updateDate+", "+emailAddress+", "+absolutePath);
var myrow = {cfgid:cfgid, '':'', cfgname:cfgname, hostname:hostname, cfgDesc:cfgDesc, productId:productId,hostname:hostname,cfgType:cfgType,emailAddress:emailAddress,absolutePath:absolutePath};
$("#list1").addRowData("1", myrow);
$("#list1").trigger("reloadGrid");
}

var grid = jQuery("#list1");

            grid.jqGrid({

              datastr : xml,
              datatype: 'xmlstring',
              colNames:['cfgId','','Name', 'Host', 'Description','Product', 'Type', 'Last Updated Time','Last Updated By',''],
              colModel:[
                  {name:'cfgId',index:'cfgId', width:90, align:"right", hidden:true},
                  {name:'',index:'', width:15, align:"right",edittype:'checkbox',formatter: "checkbox",editoptions: { value:"True:False"},editable:true,formatoptions: {disabled : false}},
                  {name:'cfgName',index:'cfgName', width:90, align:"right"},
                  {name:'hostname',index:'hostname', width:90, align:"right"},
                  {name:'cfgDesc',index:'cfgDesc', width:90, align:"right"},
                  {name:'productId',index:'productId', width:60, align:"right"},
                  {name:'cfgType',index:'cfgType', width:60, align:"right"},
                  {name:'updateDate',index:'updateDate', width:120, align:"right"},
                  {name:'emailAddress',index:'emailAddress', width:120, align:"right"},
                  {name:'absolutePath',index:'absolutePath', width:90, align:"right", hidden:true},
              ],
              pager : '#gridpager',
              rowNum:10,
              scrollOffset:0,
              height: 'auto',

              autowidth:true,
              viewrecords: true,
              gridview: true,
              xmlReader: {
                  root : "list",
                  row: "com\\.abc\\.db\\.ConfigInfo",
                  userdata: "userdata",
                  repeatitems: false
              },
              onSelectRow: function(id,status){
                  var rowData = jQuery(this).getRowData(id); 
                  configid = rowData['cfgId'];
                  /*configname=rowData['cfgName'];
                  configdesc=rowData['cfgDesc'];
                  configenv=rowData['cfgType'];
                  filename=rowData['fileName'];
                  updatedate=rowData['updateDate'];
                  absolutepath=rowData['absolutePath'];*/
                  if(status==true)
                  {

                  }

                  rowChecked=1;
                  currentrow=id;
                  }
}
               }

            });
            grid.jqGrid('navGrid','#gridpager',{edit:false,add:false,del:false});

Here is a snapshot

enter image description here

Upvotes: 0

Views: 2732

Answers (1)

Oleg
Oleg

Reputation: 221997

There are some errors in your code.

The first error: as you fill myrow = {...} you set cfgname:cfgname instead of cfgName:cfgname (your column in the grid has name:'cfgName' property and not name:'cfgname')

The second error: you display only the updateDate with respect of console.info, but don't set the property updateDate:updateDate of the myrow.

Upvotes: 1

Related Questions