jQWidgets Forums
jQuery UI Widgets › Forums › Grid › How to use dataAdapter in jqxgrid/customrowcelledit.htm demo
Tagged: customrowedit, data adapter, dataadapter, edit, editor, grid, jqxDataAdapter, row, row editor
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 10 years, 3 months ago.
-
Author
-
Hi there.
I’m following the demo (http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/customrowcelledit.htm?arctic) to make a property page.
And I need cells of ‘Country’ row (in demo) to display the text in $.jqx.dataAdapter.For example:
I have countryAdapter as below
var countryAdapter = new $.jqx.dataAdapter({
datatype: ‘json’,
localdata: [{cd:’GM’, text:’Germany’},{cd:’US’, text:’United States’}],
datafields: [{name: ‘cd’, name: ‘text’}]
}, {autoBind: true});I would like to use countryAdapter for cells of ‘Country’ row.
When cell value is ‘GM’, it will display ‘Germany’ instead of ‘GM’.Would you please advice or give me the sample code to do this. Many Thanks.
Hi ph80,
As you can see from the demo’s source code, the “Country” row is loaded through data adapter (dataAdapter). I assume you wish to set your countryAdapter as a source of the dropdownlist cell editors. In that case, you need to modify the following part of the createGridEditor function definition:
else if (row == 1) { editor.jqxDropDownList({autoDropDownHeight: true, width: width, height: height, source: createGridEditor }); }
Please note, however, that your datafields definition is incorrect. It should be:
datafields: [{ name: 'cd' }, { name: 'text' }]
.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
Thank you so much. I got it.
However, I don’t mention the dropdownlist cell editors.
What I need is the grid should display country-name instead of country-code (view data) when page is loaded.For more detail, I changed data as below (…”Berlin”: “GM”, “Boston”: “US”, “London”: “UK”…)
var data = new Array();
data.push({ “Name”: “Population”, “Berlin”: “3560154”, “Boston”: “3406829”, “London”: “8174100” });
data.push({ “Name”: “Country”, “Berlin”: “GM”, “Boston”: “US”, “London”: “UK” });
data.push({ “Name”: “Capital”, “Berlin”: “true”, “Boston”: “false”, “London”: “true” });At this time, grid will display “GM”, “US”, “UK” ( ref. http://jsfiddle.net/ph80/pz39Lu7a/ )
I want:
When page is loaded, the grid will use countryAdapter to retrieve country-name and then display it on cell (ex: cell will display “Germany”, “United States”, “United Kingdom”)Hope to find your advice.
Best regards.Hi ph80,
Here is how you can achieve your requirement: http://jsfiddle.net/Dimitar_jQWidgets/t5jLmv4b/.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.