Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
sorting: zero values not sorted
Tags: sort zero
06/02/2014
00:03
Avatar
lili5058
Member
Members
Forum Posts: 7
Member Since:
09/08/2013
sp_UserOfflineSmall Offline

My colModel has the following definition for a column:

{name:overrdAmt, width:25, formatter:'currency', formatoptions:{decimalPlaces:0,prefix:'$',defaultValue:' '}, sortable:true, sorttype:'currency', align:'right',editable:true, edittype:'text', editrules:{number:true}, cellattr:amountOverrideCellAttr},

some of the values are 0 (zero), but when I sort, 0 values are not included. I tried sorttype: int and well as float, but doesn't seem to matter.

Am I missing something?

07/02/2014
11:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

We missed a lot of things that we need to know.

By example - are you using local data or server side obtaining a data.

If you are in second kase you will need to check your server side code when a sort is on.

I need a full grid setup and simple data in order to see where the problem was.

Kind Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

07/02/2014
16:23
Avatar
lili5058
Member
Members
Forum Posts: 7
Member Since:
09/08/2013
sp_UserOfflineSmall Offline

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:

		var billGrid;
		var selRowId = null;
		var colModelNames = [${colModelNames}];
		// [ 'serviceName', 'CI_NAME','CI_TYPE','UDDS', 'amount', 'ovrrdAmount', 'isCmdbDataValid','billingCodeCmdb','ovrrdBillingCode','isBillingCodeValid','billYorN', 'isSplitBilling', 'isNonCI']
		var emptyMsgDiv = $('
There are no unposted rows
'); $(function(){ var targetPage = 1; billGrid = $("#list").jqGrid({ url:"${createLink(controller:'physicalBilling', action:'getBillData', id:billing.id)}", datatype: 'json', mtype: 'GET', 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'], colModel :[ {name:colModelNames[0], width:60, sortable:true, sorttype:'text'}, {name:colModelNames[1], width:70, editable:true, edittype:'text', editoptions:{readonly:'readonly'}, formatter:formatCiName, unformat:unformatCiName}, {name:colModelNames[2], width:50, sortable:true, sorttype:'text'}, {name:colModelNames[3], width:30, sortable:true}, {name:colModelNames[4], width:30, sortable:true, sorttype:'currency', align:'right', formatter:'currency', formatoptions:{decimalPlaces:0,prefix:'$'}}, {name:colModelNames[5], width:25, formatter:'currency', formatoptions:{decimalPlaces:0,prefix:'$',defaultValue:' '}, sortable:true, sorttype:'currency', align:'right', editable:true, edittype:'text', editrules:{number:true}, cellattr:amountOverrideCellAttr}, {name:colModelNames[6], width:30, align:'center', formatter:overrideOrInvalidContent, cellattr:overrideOrInvalidCellAttr}, {name:colModelNames[7], width:50, sortable:true}, {name:colModelNames[8], width:50, editable:true, sortable:true}, {name:colModelNames[9], width:25, align:'center', formatter:overrideOrInvalidContent, cellattr:overrideOrInvalidCellAttr}, {name:colModelNames[10], width:15, align:'center', sortable:true, formatter:overrideOrInvalidContent, cellattr:overrideOrInvalidCellAttr,editable:true, edittype:'select',editoptions:{value:{'y':'yes','n':'no'}} }, {name:colModelNames[11], hidden:true}, {name:colModelNames[12], hidden:true} ], width: '1000', height: '100%', pager: '#pager', rowNum:20, rowList:[10,20,50,100,500], viewrecords: true, gridview: true, loadonce: true, footerrow : true, rowTotal:1000, sortname:'CI_NAME', ignoreCase:true, subGrid: true, //jsonReader: {repeatitems: false}, 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: ['CI Validation Notes','Billing Code Validation Notes','Base CI Data'], 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"'; }; }, editurl:"${createLink(controller:'billableServiceItem', action:'editPerformed')}", caption: 'Physical Items to be billed', onSelectRow: function(rowId, status, e){ selRowId = rowId; var selRowData = billGrid.getRowData(selRowId); if (selRowData.isSplitBilling == "n"){ $("#createSplitBtn").removeAttr('disabled'); $("#deleteSplitBtn").attr('disabled', 'disabled'); } else { $("#createSplitBtn").attr('disabled', 'disabled'); $("#deleteSplitBtn").removeAttr('disabled'); } $("#editRowBtn").removeAttr('disabled'); if (selRowData.isNonCI == 'true'){ $("#refreshBtn").attr('disabled', 'disabled'); } else { $("#refreshBtn").removeAttr('disabled'); } }, onPaging : function(){ disableButtonsForNoSelectedRow(); }, loadComplete: onLoadComplete, }).navGrid('#pager', {add:false, del:false, edit:false, refresh:false, search:true},{},{},{},{},{});

Sample data from the server:

{"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}}
10/02/2014
15:19
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I have just tested your example. By the way there are alot of code which is missing.

I need to delete a lot of code and not sure if this is ok.

Now to the question - in my enviroment everthing work fine. The sorting is fine.

Maybe you will need give me a more data to test.

Your data for the field does not contain 0 (zero), but null which is quiet different. 

If you replace these values to 0 you will see that the displayed field is canged too.

If you want a help, please post or send a full working test case.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

10/02/2014
17:10
Avatar
lili5058
Member
Members
Forum Posts: 7
Member Since:
09/08/2013
sp_UserOfflineSmall Offline

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

}

}

]

11/02/2014
16:57
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Here is your example

As far as I see the sort is fine. Note that 0 and null are treated as same way so it is possible that some zero

0 values are between the empty ones. Is this the problem?

Regards

P.S. To overcome this problem you can define a custon sorttype which return the original value

something like this:

{

name:colModelNames[5],

width:25,

formatter:'currency',

formatoptions:{decimalPlaces:0,prefix:'$',defaultValue:' '},

sortable:true,

sorttype:function(v){return v;}, // or what you want if the v is null

align:'right',

editable:true,

edittype:'text',

editrules:{number:true}

}

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

11/02/2014
19:17
Avatar
lili5058
Member
Members
Forum Posts: 7
Member Since:
09/08/2013
sp_UserOfflineSmall Offline
Thank you for that answer. Smile
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
it harder to see). This function does the trick for me.

sorttype:function(v){ if (v == null){ return -1; } return v; }
Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
43 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information