jQWidgets Forums
jQuery UI Widgets › Forums › Lists › ListBox › Text+Value = displayMember in jqxListBox checkboxes: true
Tagged: jQuery ListBox Widget
This topic contains 3 replies, has 2 voices, and was last updated by panky 11 years, 9 months ago.
-
Author
-
Hi
I am trying to set displayMember [pom.Name = pom.Name + ” – ” + pom.Type;] as below, but it didn’t work.
Any suggestion?
ServiceCall('GET', "pom/", null, onSuccess); function onSuccess(data) { if (data) { var theme = getDemoTheme(); var source = { datatype: "json", datafields: [ { name: 'Name', type: 'string' }, { name: 'POMID', type: 'int' }, { name: 'Type', type: 'string' } ], localdata: data }; var dataAdapter = new $.jqx.dataAdapter(source, { autoBind: true, beforeLoadComplete: function (records) { var dt = new Array(); for (var i = 0; i < records.length; i++) { var pom = records[i]; pom.Name = pom.Name + " - " + pom.Type; pom.POMID = pom.POMID; dt.push(pom); } return dt; } }); // Create a jqxListBox $("#listboxPOM").jqxListBox({ source: dataAdapter, displayMember: "Name", valueMember: "POMID", checkboxes: true, width: 450, height: 125, theme: theme }); }
Thanks
Hi,
The displayMember and valueMember can be set to String only. In case you wish to customize the rendering of the ListBox items see: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxlistbox/rendering.htm?web
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks Peter
But I am trying to do
pom.Name = pom.Name + ” – ” + pom.Type;where both Name and Type are string
datafields: [
{ name: ‘Name’, type: ‘string’ },
{ name: ‘POMID’, type: ‘int’ },
{ name: ‘Type’, type: ‘string’ }
],Thanks Peter
I added renderer and it worked as I expected 🙂
// Create a jqxListBox
$(“#listboxPOM”).jqxListBox({ source: dataAdapter, displayMember: “Name”, valueMember: “POMID”,
checkboxes: true, width: 450, height: 125, theme: theme, renderer:
function (index, label, value) {
var datarecord = data[index];
return datarecord.Name + ” – ” + datarecord.Type;
}
});Thanks again.
-
AuthorPosts
You must be logged in to reply to this topic.