jQuery UI Widgets › Forums › Grid › date formatting not working
Tagged: cellsformat, database, date, date format, format, jqxgrid, SQL Server, SQL Server database
This topic contains 3 replies, has 2 voices, and was last updated by owen11 9 years, 10 months ago.
-
Author
-
Hi
I’m pretty new to JQWidgets and I am having difficulty getting date formats to work on a grid.
I am trying to integrate jqwidgets into an MVC project, drawing data from an SQL Server DB (executing stored procedures).
I have tried many different iterations that I have come across on this site and others.Here is the latest:
var model = {
patientId: patientIdNotes
};var PatientNotesSource = {
type: ‘POST’,
datatype: ‘json’,
data: model,
url: ‘../Notes/GetPatientsNotes’,
datafield: [
{ name: ‘patientNoteId’, type: ‘int’ },
{ name: ‘patientID’, type: ‘string’ },
{ name: ‘noteSubject’, type: ‘string’ },
{ name: ‘noteDateTime’, type: ‘date’, format: ‘MM/dd/yyyy HH:mm:ss’ },
{ name: ‘note’, type: ‘string’ }]
};var PatientNotesAdapter = new $.jqx.dataAdapter(PatientNotesSource);
PatientNotesGrid.jqxGrid({
width: ‘100%’,
selectionmode: ‘singlerow’,
source: PatientNotesAdapter,
altrows: true,
rowsheight: 30,
autoheight: true,
filterable: true,
showfilterrow: true,
groupable: true,
pagesize: 15,
columns: [
{ text: ‘Subject’, datafield: ‘noteSubject’, columntype: ‘textbox’, width: ‘18%’ },
{ text: ‘Note’, datafield: ‘note’, columntype: ‘textbox’, width: ‘51%’ },
{ text: ‘Date’, cellsformat: ‘MM/dd/yyyy HH:mm:ss’, datafield: ‘noteDateTime’, columntype: ‘date’, width: ‘19%’, filtertype: ‘date’ },
{ text: ”, cellsrenderer: PatientNotesGridRenderer, width: ‘12%’ }
],
});
}Regardless of what I try, leaving out the date format ‘, format: ‘MM/dd/yyyy HH:mm:ss” from the datafields, and trying different variations of cells format, I end up with the following each time in the grid cell:
/Date(1425387835650)/any suggestions, thanks!
Hello owen11,
The datafield format has to be set to the format of the date received from the database, not the one you wish to see in your grid cells (the column cellsformat). Maybe this is the cause of the issue.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thanks for coming back to me Dimitar, I’ll check it out
-
AuthorPosts
You must be logged in to reply to this topic.