jQuery UI Widgets › Forums › Grid › Date sorting
This topic contains 4 replies, has 2 voices, and was last updated by Dimitar 10 years, 8 months ago.
-
AuthorDate sorting Posts
-
I have a date column which displays date in multiple formats (“MMMM-dd-yy”,”dd MMMM yyyy”,”dddd, MMMM dd, yyyy”). Currently it is sorting as string .I tried changing the datatype to ‘date’, but it didnt work. How to perform date sorting for this?
Hello Siva,
Please share your source definition and grid initialization code so that we may determine what causes the issue.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/function getAdapter() {
var source =
{
datatype: “json”,
datafields:
[
{ name: ‘Type’, type: ‘string’ },
{ name: ‘Date’, type: ‘string’},
{ name: ‘IsSecure’, type: ‘string’ }],
url: urlGetAllJobs,
async: true
};$grid = $(“#jqxgrid_joblist”);
$grid.jqxGrid({
width: ‘100%’,
height: getInnerHeight(),
columnsheight: columnsheight,
rowsheight:rowsheight,
scrollbarsize: 8,
source: getAdapter(),
theme: theme,
columnsresize: true,
sortable: true,
columnsreorder: true,
enablehover: true,
enabletooltips: true,
showemptyrow: false,
showtoolbar: false,
sorttogglestates: 1,
groupable: false,columns:
{
text: ”, datafield: ‘Type’, filtertype: ‘checkedlist’,
renderer: headerRenderer,
cellsrenderer: imageRenderer,
width: ‘5%’,
resizable: false
},
{
text: ‘date;, datafield: ‘Submission’,
renderer: columnsHeaderStyle,
cellsrenderer: rowsCellStyle,
filtertype: ‘date’,
width: ‘15%’,
}
});here date is in string, so,i get unexpected results. I need to sort it in date format.
Any answers please??
Thanks in advanceHi Siva,
There are several issues in your code:
1) the type of the “Date” datafield should be set to “date”, not “string”:
{ name: 'Date', type: 'date'},
2) In the second column definition there is a typo – ; instead of ‘:
text: 'date'
3) The same column also does not refer to an existing datafield in the source. I think you should change “Submission” to “Date” (which is defined).
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.