jQWidgets Forums
jQuery UI Widgets › Forums › Grid › DisplayField incorrectly used for sorting
Tagged: datagrid widget sorting
This topic contains 5 replies, has 3 voices, and was last updated by Peter Stoev 6 years, 8 months ago.
-
Author
-
I have a local data source which has two different fields, one that is a pre-formatted display value of type string and one which is the raw numeric value. I’d like to have the sorting use the datafield and the grid display the displayfield. I thought I could just set the column definition to use the two fields as shown in the JSFiddle below but it appears that when you specify a displayfield the default sorting uses this field instead of the datafield for sorting. Is this a bug or am I missing something?
Hi piobst,
Sorting is always by displayField. Your problem is that the displayField’s type is incorrect.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Well, the display field is of type string because it is a formatted value (e.g. “$1,234.00”) so I couldn’t make this field type numeric. When you say that sorting is always by displayField, what if you didn’t specify a displayField (only a datafield)? Wouldn’t it sort by datafield in that case?
My basic question is, is there any way (using displayField vs. datafield or any other technique) to allow the grid to show values in the grid based on one field in my data source and then sort that same column based on another value in my data source?
Hi piobst,
If the field’s type is “string” then the sorting would be by “string” as well. Yes, if you don’t set the displayField, the dataField would be used instead. If you want to customize the default sorting, see: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/customsorting.htm?arctic
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/So, when displayfield is set, datafield is used for nothing? Then what’s the reason to have a datafield?
Wouldn’t it be more logical to make the “internal data workings” with the datafield and the displayfield used only for display? (As its name states).
datafield is used for storing the cell’s value. A column with displayfield and datafield is a column where each cell has LABEL and VALUE.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.