jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Export data from jqxgrid
Tagged: datagrid
This topic contains 3 replies, has 3 voices, and was last updated by raghu501 10 years, 1 month ago.
-
AuthorExport data from jqxgrid Posts
-
I want to export all data in my jqxgrid into json and send it to another page via AJAX. My problem is when I click export button, the data in the grid and data before export was not the same. It change float number to Interger. Here is my code:
javascript:
$('#export_bt').on('click', function(){ var row = $("#jqxgrid").jqxGrid('exportdata', 'json'); $('#debug').html(row); console.log(row); }); var tableDatas = [ {"timestamp":"06:00:00","A":99.49,"B":337.77,"C":155.98}, {"timestamp":"07:00:00","A":455.67,"B":474.1,"C":751.68}, {"timestamp":"08:00:00","A":1071.02,"B":598.14,"C":890.47} ]; var tableDatafields = [ {"name":"timestamp","type":"string"}, {"name":"A","type":"number"}, {"name":"B","type":"number"}, {"name":"C","type":"number"} ]; var tableColumns = [ {"text":"Times","datafield":"timestamp","editable":"false","align":"center","cellsalign":"center","width":150}, {"text":"A","datafield":"A","editable":"false","align":"center"}, {"text":"B","datafield":"B","editable":"false","align":"center"}, {"text":"C","datafield":"C","editable":"false","align":"center"} ]; function setTableData(table_data,table_column,table_datafields) { sourceTable.localdata = table_data; sourceTable.datafields = table_datafields; dataAdapterTable = new $.jqx.dataAdapter(sourceTable); $("#jqxgrid").jqxGrid({columns:table_column}); $("#jqxgrid").jqxGrid('updatebounddata'); $('#jqxgrid').jqxGrid('sortby', 'timestamp', 'asc'); $("#jqxgrid").jqxGrid('autoresizecolumns'); for(var i=0;i<table_column.length;i++){ $('#jqxgrid').jqxGrid('setcolumnproperty',table_column[i].datafield,'cellsrenderer',cellsrenderer); } } var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) { if (value||value===0) { return value; } else { return '-'; } }; var sourceTable ={ localdata: '', datatype: 'array'}; var dataAdapterTable = new $.jqx.dataAdapter(sourceTable); dataAdapterTable.dataBind(); $("#jqxgrid").jqxGrid({ width: '500', autoheight:true, source: dataAdapterTable, sortable: true, columnsresize: false, selectionmode: 'none', columns: [{ text: '', datafield: 'timestamp', width:'100%' , editable: false, align:'center'}] }); setTableData(tableDatas,tableColumns,tableDatafields);
html:
<div id="jqxgrid"></div> <button id="export_bt">Export</button> <div id="debug"></div>
This is my jsfiddle http://jsfiddle.net/jedipalm/jHE7k/1/
Hi jedipalm,
Thanks for the feedback! If you need just to export the data to JSON, set the dataType to String.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi,
I want to pass the result of var aupexportdata = $(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’);
to action method in ASP.NET MVC ,this method
would return Excel File.is there any feature to pass the ‘aupexportdata’ to contoller.
i am trying to pass this by using forms, i am unable to get the ‘exportdata’ result in action method.please help me.Regards
Raghu -
AuthorPosts
You must be logged in to reply to this topic.