Hello,
Â
I stumbled upon another problem, that I cant quite explain/understand.
What I am trying to do:
I load data via xmlstring and want it grouped by one column – but just configuring the grouping via grouping:true and groupingView:{…} just throws a “TypeError: b is null”
So I rummaged through some sources and came to the conclussion – that I should only group after the grid loaded the xmlstring.
loadComplete: function() {
         if(!loadedGrouping)
         {
            //We need to enable Grouping via Xml AFTER loadComplete – or we get a huge null pointer
            $(‘#list’).jqGrid(‘setGridParam’, { grouping:true });
            //$(‘#list’).jqGrid(‘setGridParam’, { sortorder:’asc’ });
            //Grouping END
            //Reload Grid once so Grouping takes effect
            $(‘#list’).trigger(“reloadGrid”);  Â
           Â
            loadedGrouping = true;
         }
Â
This seems to work – but only after I trigger a sorting change by clicking on a column header – after that the grouping works perfectly.
Here is the rest of my code:
$(“#list”).jqGrid({
       datatype: ‘xmlstring’, //Datatype of information represented, will be XML due to HTTP call I guess?
      datastr: mydata,
       colNames: ,
      colModel:[
         //GroupColumn
         {name:’xxx’, index:’xxx’,width:10,editable:true},
           {name:’itmc’,index:’itmc’, width:85, align:”left”},
           {name:’pzn’,index:’pzn’, width:65, align:”left”},
           {name:’itemnm’,index:’itemnm’, width:220, align:”left”,sorttype:”text”},
         //EditableParts
         {name:’amount’, index:’amount’, width:45,align:”center”,sorttype:”number”, editoptions:{size:5, maxlenght:4, height:40},editrules:{number:true},editable:true},
         {name:’nr’,index:’nr’,width:45,align:”center”,sorttype:”number”,editoptions:{size:5, maxlenght:4},editrules:{number:true},editable:true},
         {name:’p’, index:’p’,width:30,align:”center”,sortable:false, edittype:’checkbox’,editoptions:{value:”Ja:Nein”},editable:true},
         {name:’k’, index:’k’,width:30,align:”center”,sortable:false, edittype:’checkbox’,editoptions:{value:”Ja:Nein”},editable:true},
         {name:’a’, index:’a’,width:30,align:”center”,sortable:false, edittype:’checkbox’,editoptions:{value:”Ja:Nein”},editable:true},
         //END EditableParts
           {name:’year12′,index:’year12′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
           {name:’year13′,index:’year13′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon1′,index:’mon1′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon2′,index:’mon2′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon3′,index:’mon3′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon4′,index:’mon4′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon5′,index:’mon5′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon6′,index:’mon6′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon7′,index:’mon7′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon8′,index:’mon8′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon9′,index:’mon9′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon10′,index:’mon10′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon11′,index:’mon11′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
         {name:’mon12′,index:’mon12′, width:22, formatter:’text’, align:”right”,sorttype:”number”},
       ],
       pager: ‘#pager’,
       rowNum: 10,    Â
       //rowList: [10, 15, 20],
       sortname: ‘xxx’, Â
       sortorder: ‘asc’,Â
       viewrecords: true,
       gridview: true,  Â
       autoencode: true,
       caption: “Producer Name (Placeholder)”,
      height: 520,
      grouping:false,
      groupingView: {
         groupField:,
         groupColumnShow: [false],
         groupText: ,
         groupCollapse:false,
         //groupDataSorted: true,
         //groupOrder:
      },
      onSelectRow: function(id){
         if(id!=lastsel){
            jQuery(‘#list’).jqGrid(‘saveRow’,lastsel);
            lastsel = null;
        Â
            jQuery(‘#list’).jqGrid(‘editRow’,id,true);
            lastsel=id;
            var focusElement = id+’_NR’;
            //alert(focusElement);
            $(focusElement).focus();
            //$(document).bind(“mouseup”,function(event) {
            //   jQuery(‘#list’).jqGrid(‘getCell’,id,’NR’).focus(); //selects specific row and underlying cell and sets the focus
            //});
         }
      },
      scrollOffset: 0,
      editurl: “default.html”,
      hidegrid:false,
      loadComplete: function() { //function that manipulates ALL rows after the loading is done
         if(!loadedGrouping)
         {
            //We need to enable Grouping via Xml AFTER loadComplete – or we get a huge null pointer
            $(‘#list’).jqGrid(‘setGridParam’, { grouping:true });
            //$(‘#list’).jqGrid(‘setGridParam’, { sortorder:’asc’ });
            //Grouping END
            //Reload Grid once so Grouping takes effect
            $(‘#list’).trigger(“reloadGrid”);  Â
           Â
            loadedGrouping = true;
         }
         var grid = $(“#list”);
         var ids = grid.getDataIDs();
         for (var i = 0; i < ids.length; i++) {
            grid.setRowData ( ids, false, {height: 40} ); //change this number to manipulate Row-Height
         }
        Â
      }
   }).jqGrid(‘navGrid’,’#pager’,{add:false,edit:false,del:false});
Â
I admit I am very new to JqGrid and even Jquery and Jscript in generall – so I might missinterpreted the intent behind the events.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top