jQWidgets Forums
jQuery UI Widgets › Forums › Lists › DropDownList › How to add multiple fields to displayMember
Tagged: DropDownList, getItems
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 5 months ago.
-
Author
-
Hi.. I would like to know, is there any way to add two or more displayMembers in a DropDownList;
my code as follows.$(document).ready(function () {
var theme = “”;
var url = “../jquery/php/combo_project_list.php”;
// prepare the data
var source =
{
datatype: “json”,
datafields: [
{ name: ‘p_no’ },
{ name: ‘p_name’},
{ name: ‘client_id’},
{ name: ‘reg_date’},
{ name: ‘end_date’}],
url: url,
async: false
};
var dataAdapter = new $.jqx.dataAdapter(source);
// Create a jqxDropDownList
$(“#combo_project_list_head”).jqxDropDownList({
selectedIndex: 0, source: dataAdapter, displayMember: “p_no”, valueMember: “p_no”, width: 100, height: 18, theme: theme
});
// subscribe to the select event.
$(“#combo_project_list_head”).on(‘select’, function (event) {
if (event.args) {
var item = event.args.item;
if (item) {
var valueelement = $(““);
valueelement.text(“Value: ” + item.value);
var labelelement = $(““);
labelelement.text(“Label: ” + item.label);
$(“#combo_project_list_body”).children().remove();
$(“#combo_project_list_body”).append(labelelement);
$(“#combo_project_list_body”).append(valueelement);
}
}
});$(“#combo_project_list_head”).jqxDropDownList({ autoDropDownHeight: true });
});
and PHP file as follows;
Many thanks,
Supun SilvaHi Supun Silva,
It is not possible to have multiple displayMembers. The widget can have only one displayMember associated to 1 data property.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks for your quick reply. Is there anyway I can display 2 columns in one dropDownList while keeping one column as a ValueMember?
My other problem is,
I have tried to get $(“#combo_project_list_body”).jqxDropDownList(‘getItems’);
But it retrieved values [object Object],[object Object],[object Object]
I want to get Item count and values in a array.Below is my code;
$(“#testbtn”).on(“click”, function(){
var project_list = $(“#combo_project_list_body”).jqxDropDownList(‘getItems’);
alert(project_list);});
I have three records in database;
this is my jquery;$(document).ready(function () {
var theme = “”;
var url = “../jquery/php/combo_project_list.php”;
// prepare the data
var source =
{
datatype: “json”,
datafields: [
{ name: ‘p_no’ },
{ name: ‘p_name’},
{ name: ‘client_id’},
{ name: ‘reg_date’},
{ name: ‘end_date’}],
url: url,
async: false
};
var dataAdapter = new $.jqx.dataAdapter(source);
// Create a jqxDropDownList
$(“#combo_project_list_head”).jqxDropDownList({
selectedIndex: 0, source: dataAdapter, displayMember: “p_no”, valueMember: “p_no”, width: 100, height: 18, theme: theme
});
$(“#combo_project_list_head”).jqxDropDownList({ autoDropDownHeight: true });
});and PHP as below;
Hi supun151515,
jqxDropDownList is a single-column widget. For displaying multiple columns, you can use jqxGrid.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.