jQuery UI Widgets › Forums › DataTable › Data string going to integer
Tagged: angular datatable, bootstrap datatable, javascript datatable, jquery datatable, jqwidgets datatable, jqxdatatable, string became integer
This topic contains 1 reply, has 2 voices, and was last updated by Hristo 8 years, 9 months ago.
-
Author
-
First data in my table became integer ( should be string ) eg. “0000001” = “1”
I created this example to show you my problem. I’m using jQWidgets v3.7.0 (2015-Feb)
<html> <head> <link rel = "stylesheet" href = "http://jqwidgets.com/public/jqwidgets/styles/jqx.base.css" type = "text/css" /> <script type = "text/javascript" src = "http://jqwidgets.com/public/jqwidgets/scripts/jquery-1.11.1.min.js"> </script> <script type = "text/javascript" src = "http://jqwidgets.com/public/jqwidgets/jqxcore.js"> </script> <script type = "text/javascript" src = "http://jqwidgets.com/public/jqwidgets/jqxbuttons.js"> </script> <script type = "text/javascript" src = "http://jqwidgets.com/public/jqwidgets/jqxscrollbar.js"> </script> <script type = "text/javascript" src = "http://jqwidgets.com/public/jqwidgets/jqxdata.js"> </script> <script type = "text/javascript" src = "http://jqwidgets.com/public/jqwidgets/jqxdatatable.js"> </script> <script type = "text/javascript"> var data = []; for (var counter = 0; counter < 100; counter ++) data[counter] = { id: counter + 1, no: "00000000" + (counter + 1) }; $("#table").jqxDataTable({ columns: [ { text: "No.", dataField: "no" }, { text: "Id", dataField: "id" } ], height: 500, source: new $.jqx.dataAdapter({ dataType: "json", localData: data }), width: 500 }); </script> </head> <body> <div id = "table"> </div> </body> </html>
I tried setting the type but it still change to integer.
Hoping you could help me.Thank you,
MarcoHello No One,
When use
dataAdapter
you could set the ‘type’.
Please take a look Your code below with little changes:<html> <head> <link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="http://jqwidgets.com/public/jqwidgets/scripts/jquery-1.11.1.min.js"> </script> <script type="text/javascript" src="http://jqwidgets.com/public/jqwidgets/jqxcore.js"> </script> <script type="text/javascript" src="http://jqwidgets.com/public/jqwidgets/jqxbuttons.js"> </script> <script type="text/javascript" src="http://jqwidgets.com/public/jqwidgets/jqxscrollbar.js"> </script> <script type="text/javascript" src="http://jqwidgets.com/public/jqwidgets/jqxdata.js"> </script> <script type="text/javascript" src="http://jqwidgets.com/public/jqwidgets/jqxdatatable.js"> </script> <script type="text/javascript"> $(document).ready(function () { var data = []; for (var counter = 0; counter < 100; counter++) { data[counter] = { id: counter + 1, no: "00000000" + (counter + 1) }; } var dataAdapter = new $.jqx.dataAdapter({ dataType: "json", dataFields: [ { name: 'id', type: 'int' }, { name: 'no', type: 'string' }, ], localData: data }); $("#table").jqxDataTable({ height: 500, width: 500, source: dataAdapter, columns: [ { text: "No.", dataField: "no" }, { text: "Id", dataField: "id" } ], }); }); </script> </head> <body> <div id="table"></div> </body> </html>
We would like to recommend you to use new version of jQWidgets.
Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.