jQWidgets Forums
jQuery UI Widgets › Forums › Grid › [object Object] instead of empty string
Tagged: jqxGrid mapping
This topic contains 4 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 11 months ago.
-
Author
-
Hi!
I use JSON data source with mapping. Each field from record contains two fields: ‘dv’ and ‘rv’. Grid columns are mappied to ‘dv’ field. If ‘dv’ is not empty then all is working correctly, else we can see [object Object] instead of empty string.
Here is my code:
var datafields = [], columns = []; $.each(data.data.Columns, function() { var type = getDataType(this.DataType); var name = this.Name; if (name == 'Name') alert('The field can not be named as Name'); datafields.push({ name: name, map: this.Name + '>dv', type: type }); columns.push({ text: this.Caption, datafield: name, width: this.Width }); }); var source = { datatype: 'json', type: "POST", datafields: datafields, url: '@Url.Action("GridData", "View")', data: data.postData || { view: data.viewName }, root: 'records', id: 'id', beforeprocessing: function(d) { source.totalrecords = d.data.total; } }; var dataAdapter = new $.jqx.dataAdapter(source); var gridSettings = { source: dataAdapter, columns: columns, pageable: true, columnsresize: true, virtualmode: true, rendergridrows: function(obj) { return obj.data; }, height: '100%', width: '100%', showtoolbar: true, toolbarheight: 25, rendertoolbar: function(toolbar) { var container = $("<div style='margin: 5px'></div>"); var span = $("<span style='float: left;margin-right: 4px'></span>"); span.text(data.data.Caption); toolbar.append(container); container.append(span); } }; grid.jqxGrid(gridSettings);
I can implement russian l10n for jqxGrid widget if you fix the problem.
Hi Yuri Antipin,
Unfortunately, the provided sample is not sufficient for illustrating the reported behavior. If you wish from us to test that scenario, then please provide a complete sample that showcases your scenario and which we will be able to run.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter Stoev, thanks for your reply.
This example illustrates a bug:<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8" /> <title>jxgGrid mapping error</title> <link rel="stylesheet" href="styles/jqx.base.css"/> <script type="text/javascript" src="scripts/jquery-1.10.2.min.js"> </script> <script type="text/javascript" src="scripts/jqx-all.js"> </script> <script type="text/javascript"> $(document).ready(function() { var inputData = { data: { records: [{ columnName1: { dv: '', rv: '' }, columnName2: { dv: '', rv: '' } }, { columnName1: { dv: 'column1', rv: 'column1' }, columnName2: { dv: 'column2', rv: 'column2' } }] } }; var datafields = [{ name: 'columnName1', map: 'columnName1>dv' }, { name: 'columnName2', map: 'columnName2>dv' }], columns = [{ text: 'Column 1', datafield: 'columnName1' }, { text: 'Column 2', datafield: 'columnName2' }]; var source = { datatype: 'json', datafields: datafields, root: 'records', localdata: inputData }; var dataAdapter = new $.jqx.dataAdapter(source); var gridSettings = { source: dataAdapter, columns: columns }; $('#grid').jqxGrid(gridSettings); }); </script> </head> <body> <div id="grid" /> </body></html>
Hi Yuri Antipin,
We reproduced the reported behavior and will do our best to resolve it for jQWidgets ver. 3.0
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.