Here is the text from
var billGrid;
var colModelNames = [ ‘serviceName’, ‘CI_NAME’, ‘volumeName’,’CI_TYPE’,’UDDS’, ‘amount’, ‘billingCodeCmdb’, ‘ovrrdBillingCode’, ‘isSplitBilling’, ‘billingCodeType’];
var emptyMsgDiv = $(‘There are no unposted rows’);
$(function(){
var targetPage = 1;
billGrid = $(“#list”).jqGrid({
url:”${createLink(controller:’storageBilling’, action:’getSummaryBillData’, params:[id:billing.id, postedStatus: ‘canBePosted’])}”,
datatype: ‘json’,
mtype: ‘GET’,
colNames:[ ‘SEO Service billed’, ‘CI billed’, ‘Volume Name’,’CI Type’,’UDDS’, ‘Amount Billed’,’CMDB Billing code’,’Billing Code Override’, ‘Split’, ‘Billing Code Type’, ‘SourceBillable’],
colModel :[
{name:colModelNames[0],width:60, sortable:true, sorttype:’text’},
{name:colModelNames[1], width:50, editable:true, edittype:’text’, formatter:formatCiName},
{name:colModelNames[2], width:70, sortable:true, sorttype:’text’},
{name:colModelNames[3], width:50, sortable:true, sorttype:’text’},
{name:colModelNames[4], width:30, sortable:true},
{name:colModelNames[5], width:30, sortable:true, align:’right’, formatter:’currency’, sorttype:’currency’,
formatoptions:{decimalPlaces:0,prefix:’$’},summaryType:’sum’},
{name:colModelNames[6], width:50, editable:true, sortable:true},
{name:colModelNames[7], width:50, editable:true, sortable:true},
{name:colModelNames[8], width:50},
{name:colModelNames[9],hidden:true},
{name:’sourceBillable’, hidden:true}
],
width: ‘1000’,
toppager:true,
height: ‘100%’,
pager: ‘#pager’,
rowNum:1000,
rowList:[10,20,50,100,1000],
viewrecords: true,
gridview: true,
jsonReader:{repeatitems: false},
loadonce: true,
footerrow : true,
grouping:true,
groupingView: {
groupField:,
groupOrder:,
groupSummary:[true,true],
groupColumnShow:[false,false],
groupCollapse:false,
},
subGrid: true,
subGridRowExpanded: function(subgrid_id, row_id) {
var subgrid_table_id;
subgrid_table_id = subgrid_id+”_t”;
jQuery(“#”+subgrid_id).html(“
“);
jQuery(“#”+subgrid_table_id).jqGrid({
url:’${createLink(controller:’billableServiceItem’, action:’getDetails’)}&id=’ + row_id,
datatype: “json”,
colNames: ,
colModel: [
{name:”valnotes”,index:”valnotes”,width:200, cellattr:detailsFormatter},
{name:”billval”,index:”billval”,width:200, cellattr:detailsFormatter},
{name:”cidetails”,index:”cidetails”,width:400,formatter:ciDetailsFormatter},
],
height: ‘100%’,
});
function ciDetailsFormatter(cellvalue, options, rowObject){
var ciObj = jQuery.parseJSON(cellvalue);
var ciObjStr = “”;
for (var prop in ciObj){
if (ciObj.hasOwnProperty(prop)){
ciObjStr = ciObjStr + prop + “: ” + ciObj[prop] + “, “;
}
}
return ‘‘ + ciObjStr + ‘‘;
};
function detailsFormatter(rowId, val, rawObject, cm){
return ‘class=”wrapTableCell”‘;
};
},
caption: ‘Storage Items to be billed’,
loadComplete: onLoadComplete,
}).navGrid(‘#list_toppager’, {add:false, del:false, edit:false, refresh:false, search:false},{},{},{},{},{});
|
1 2 3 4 5 6 |
Thank you for that answer. <img decoding="async" title="Smile" src="/blog/wp-content/forum-smileys/sf-smile.gif" alt="Smile" /><br />I didn't realized that 0 and null were treated the same, but it makes sense if you look at it closely (that fact that nulls appear blank make<br />it harder to see). This function does the trick for me.<br /><br />sorttype:function(v){<br /> if (v == null){<br /> return -1;<br /> }<br /> return v;<br /> }<br /> |
Here is some different data. One cell has ovrrdAmount: 0, most have null, some have a few different values.
Is there a way to upload screenshots? Unfortuately the site is not publicly available so I can give a link.
[
{
“id”: 128650,
“cell”: {
“serviceName”: “Physical Hosting-Tape Library Frame (Storage)”,
“CI_NAME”: “ACD-CALL-LOGGER-1”,
“CI_TYPE”: “Server-Appliance”,
“UDDS”: “A-06-5043”,
“amount”: 50,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-5043”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128570,
“cell”: {
“serviceName”: “Physical Hosting-Tape Library Frame (Storage)”,
“CI_NAME”: “ACD-CALL-LOGGER-2”,
“CI_TYPE”: “Server-Appliance”,
“UDDS”: “A-06-5043”,
“amount”: 50,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-5043”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128607,
“cell”: {
“serviceName”: “Physical Hosting-Tape Library Frame (Storage)”,
“CI_NAME”: “ACD-REMOTE-1”,
“CI_TYPE”: “Server-Appliance”,
“UDDS”: “A-06-5043”,
“amount”: 50,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-5043”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128521,
“cell”: {
“serviceName”: “Physical Hosting-Tape Library Frame (Storage)”,
“CI_NAME”: “ACD-REMOTE-2”,
“CI_TYPE”: “Server-Appliance”,
“UDDS”: “A-06-5043”,
“amount”: 50,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-5043”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128335,
“cell”: {
“serviceName”: “Physical Hosting-Firewalll (Network)”,
“CI_NAME”: “ADAMS”,
“CI_TYPE”: “Network-Firewall”,
“UDDS”: “A-06-0170”,
“amount”: 50,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “10004827.001.99”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128532,
“cell”: {
“serviceName”: “Physical Hosting-Tape Library Frame (Storage)”,
“CI_NAME”: “ADIX (HD-ACD)”,
“CI_TYPE”: “Server-Appliance”,
“UDDS”: “A-06-5043”,
“amount”: 500,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-5043”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128311,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “ADRIC”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-7171”,
“amount”: 253,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-7171”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128701,
“cell”: {
“serviceName”: “Physical Hosting-Tape Library (Storage)”,
“CI_NAME”: “ADRICR”,
“CI_TYPE”: “NONE”,
“UDDS”: null,
“amount”: null,
“ovrrdAmount”: 20,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: null,
“ovrrdBillingCode”: “A”,
“isBillingCodeValid”: “n”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: true
}
},
{
“id”: 128603,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “ADX-MASTER1”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-4190”,
“amount”: 237,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “10004986.002”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128278,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “ADX-MASTER2”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-4190”,
“amount”: 237,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “10004986.002”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128480,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “ALLIGATOR”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-7180”,
“amount”: 237,
“ovrrdAmount”: 112,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “10004791.103”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128681,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “ALLIGATOR”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-7180”,
“amount”: 237,
“ovrrdAmount”: 125,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “10004791.103”,
“ovrrdBillingCode”: “A-06-4089”,
“isBillingCodeValid”: “n”,
“billYorN”: “y”,
“isSplitBilling”: “y”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128305,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “AMBROSIA”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-4281”,
“amount”: 302,
“ovrrdAmount”: 0,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-4281”,
“ovrrdBillingCode”: “D000243”,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128274,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “AMENHOTEP”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-4029”,
“amount”: 237,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-4029”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128448,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “AMUN”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-4029”,
“amount”: 237,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-4029”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128604,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “ANTIGONISH”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-4026”,
“amount”: 286,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “10003130.700”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128436,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “ANUBIS”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-4029”,
“amount”: 237,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-4029”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
},
{
“id”: 128509,
“cell”: {
“serviceName”: “Physical Hosting-Full”,
“CI_NAME”: “ARIAL”,
“CI_TYPE”: “Server-Physical-RackMount”,
“UDDS”: “A-06-7173”,
“amount”: 237,
“ovrrdAmount”: null,
“isCmdbDataValid”: “yes”,
“billingCodeCmdb”: “A-06-7173”,
“ovrrdBillingCode”: null,
“isBillingCodeValid”: “y”,
“billYorN”: “y”,
“isSplitBilling”: “n”,
“volumeName”: null,
“isNonCI”: false
}
}
]
Sure, of course. Here is the info you need. I'm getting the data from the server, but switching to local data with the loadone:true. There is a bit of Grails code in the following snippets, FYI.
Full grid setup:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
var billGrid;<br /> var selRowId = null;<br /> var colModelNames = [${colModelNames}];<br /> // [ 'serviceName', 'CI_NAME','CI_TYPE','UDDS', 'amount', 'ovrrdAmount', 'isCmdbDataValid','billingCodeCmdb','ovrrdBillingCode','isBillingCodeValid','billYorN', 'isSplitBilling', 'isNonCI']<br /> var emptyMsgDiv = $('<div class="noRows">There are no unposted rows</div>');<br /> $(function(){<br /> var targetPage = 1;<br /> billGrid = $("#list").jqGrid({<br /> url:"${createLink(controller:'physicalBilling', action:'getBillData', id:billing.id)}",<br /> datatype: 'json',<br /> mtype: 'GET',<br /> colNames:[ 'SEO Service billed', 'Service Name (CI) billed','CI Type','UDDS', 'Calculated Amount', 'Override Amt', 'CMDB Data Is Valid','CMDB Billing code','Billing Code Override','Billing Code is Valid','Bill?', 'Split', 'isNonCI'],<br /> colModel :[<br /> {name:colModelNames[0], width:60, sortable:true, sorttype:'text'},<br /> {name:colModelNames[1], width:70, editable:true, edittype:'text',<br /> editoptions:{readonly:'readonly'}, formatter:formatCiName, unformat:unformatCiName},<br /> {name:colModelNames[2], width:50, sortable:true, sorttype:'text'},<br /> {name:colModelNames[3], width:30, sortable:true},<br /> {name:colModelNames[4], width:30, sortable:true, sorttype:'currency', align:'right', formatter:'currency',<br /> formatoptions:{decimalPlaces:0,prefix:'$'}},<br /> {name:colModelNames[5], width:25, formatter:'currency',<br /> formatoptions:{decimalPlaces:0,prefix:'$',defaultValue:' '}, sortable:true, sorttype:'currency', align:'right',<br /> editable:true, edittype:'text', editrules:{number:true}, cellattr:amountOverrideCellAttr},<br /> {name:colModelNames[6], width:30, align:'center',<br /> formatter:overrideOrInvalidContent, cellattr:overrideOrInvalidCellAttr},<br /> {name:colModelNames[7], width:50, sortable:true},<br /> {name:colModelNames[8], width:50, editable:true, sortable:true},<br /> {name:colModelNames[9], width:25, align:'center',<br /> formatter:overrideOrInvalidContent, cellattr:overrideOrInvalidCellAttr},<br /> {name:colModelNames[10], width:15, align:'center', sortable:true,<br /> formatter:overrideOrInvalidContent, cellattr:overrideOrInvalidCellAttr,editable:true,<br /> edittype:'select',editoptions:{value:{'y':'yes','n':'no'}} },<br /> {name:colModelNames[11], hidden:true},<br /> {name:colModelNames[12], hidden:true}<br /> ],<br /> width: '1000',<br /> height: '100%',<br /> pager: '#pager',<br /> rowNum:20,<br /> rowList:[10,20,50,100,500],<br /> viewrecords: true,<br /> gridview: true,<br /> loadonce: true,<br /> footerrow : true,<br /> rowTotal:1000,<br /> sortname:'CI_NAME',<br /> ignoreCase:true,<br /> subGrid: true,<br /> //jsonReader: {repeatitems: false},<br /> subGridRowExpanded: function(subgrid_id, row_id) {<br /> var subgrid_table_id;<br /> subgrid_table_id = subgrid_id+"_t";<br /> jQuery("#"+subgrid_id).html("");<br /> jQuery("#"+subgrid_table_id).jqGrid({<br /> url:'${createLink(controller:'billableServiceItem', action:'getDetails')}&id=' + row_id,<br /> datatype: "json",<br /> colNames: ['CI Validation Notes','Billing Code Validation Notes','Base CI Data'],<br /> colModel: [<br /> {name:"valnotes",index:"valnotes",width:200, cellattr:detailsFormatter},<br /> {name:"billval",index:"billval",width:200, cellattr:detailsFormatter},<br /> {name:"cidetails",index:"cidetails",width:400,formatter:ciDetailsFormatter},<br /> ],<br /> height: '100%',<br /> });<br /> function ciDetailsFormatter(cellvalue, options, rowObject){<br /> var ciObj = jQuery.parseJSON(cellvalue);<br /> var ciObjStr = "";<br /> for (var prop in ciObj){<br /> if (ciObj.hasOwnProperty(prop)){<br /> ciObjStr = ciObjStr + prop + ": " + ciObj[prop] + ", ";<br /> }<br /> }<br /> return '<span>' + ciObjStr + '</span>';<br /> };<br /> function detailsFormatter(rowId, val, rawObject, cm){<br /> return 'class="wrapTableCell"';<br /> };<br /> },<br /> editurl:"${createLink(controller:'billableServiceItem', action:'editPerformed')}",<br /> caption: 'Physical Items to be billed',<br /> onSelectRow: function(rowId, status, e){<br /> selRowId = rowId;<br /> var selRowData = billGrid.getRowData(selRowId);<br /> if (selRowData.isSplitBilling == "n"){<br /> $("#createSplitBtn").removeAttr('disabled');<br /> $("#deleteSplitBtn").attr('disabled', 'disabled');<br /> } else {<br /> $("#createSplitBtn").attr('disabled', 'disabled');<br /> $("#deleteSplitBtn").removeAttr('disabled');<br /> }<br /> $("#editRowBtn").removeAttr('disabled');<br /> if (selRowData.isNonCI == 'true'){<br /> $("#refreshBtn").attr('disabled', 'disabled');<br /> } else {<br /> $("#refreshBtn").removeAttr('disabled');<br /> }<br /> },<br /> onPaging : function(){<br /> disableButtonsForNoSelectedRow();<br /> },<br /> loadComplete: onLoadComplete,<br /> }).navGrid('#pager', {add:false, del:false, edit:false, refresh:false, search:true},{},{},{},{},{});<br /> |
Sample data from the server:
|
1 |
{"total":398,"page":"1","records":398,"rows":[{"id":128650,"cell":{"serviceName":"Physical Hosting-Tape Library Frame (Storage)","CI_NAME":"ACD-CALL-LOGGER-1","CI_TYPE":"Server-Appliance","UDDS":"A-06-5043","amount":50,"ovrrdAmount":null,"isCmdbDataValid":"yes","billingCodeCmdb":"A-06-5043","ovrrdBillingCode":null,"isBillingCodeValid":"y","billYorN":"y","isSplitBilling":"n","volumeName":null,"isNonCI":false}},{"id":128570,"cell":{"serviceName":"Physical Hosting-Tape Library Frame (Storage)","CI_NAME":"ACD-CALL-LOGGER-2","CI_TYPE":"Server-Appliance","UDDS":"A-06-5043","amount":50,"ovrrdAmount":null,"isCmdbDataValid":"yes","billingCodeCmdb":"A-06-5043","ovrrdBillingCode":null,"isBillingCodeValid":"y","billYorN":"y","isSplitBilling":"n","volumeName":null,"isNonCI":false}},{"id":128607,"cell":{"serviceName":"Physical Hosting-Tape Library Frame (Storage)","CI_NAME":"ACD-REMOTE-1","CI_TYPE":"Server-Appliance","UDDS":"A-06-5043","amount":50,"ovrrdAmount":null,"isCmdbDataValid":"yes","billingCodeCmdb":"A-06-5043","ovrrdBillingCode":null,"isBillingCodeValid":"y","billYorN":"y","isSplitBilling":"n","volumeName":null,"isNonCI":false}},{"id":128521,"cell":{"serviceName":"Physical Hosting-Tape Library Frame (Storage)","CI_NAME":"ACD-REMOTE-2","CI_TYPE":"Server-Appliance","UDDS":"A-06-5043","amount":50,"ovrrdAmount":null,"isCmdbDataValid":"yes","billingCodeCmdb":"A-06-5043","ovrrdBillingCode":null,"isBillingCodeValid":"y","billYorN":"y","isSplitBilling":"n","volumeName":null,"isNonCI":false}},{"id":128335,"cell":{"serviceName":"Physical Hosting-Firewalll (Network)","CI_NAME":"ADAMS","CI_TYPE":"Network-Firewall","UDDS":"A-06-0170","amount":50,"ovrrdAmount":null,"isCmdbDataValid":"yes","billingCodeCmdb":"10004827.001.99","ovrrdBillingCode":null,"isBillingCodeValid":"y","billYorN":"y","isSplitBilling":"n","volumeName":null,"isNonCI":false}} |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top