jQWidgets Forums
jQuery UI Widgets › Forums › Lists › DropDownList › 'displayMember' and 'label' field
Tagged: displayMember, DropDownList, jqxDataAdapter, jqxDropDownList
This topic contains 5 replies, has 3 voices, and was last updated by Nadezhda 10 years, 2 months ago.
-
Author
-
Hi,
I found something weired when I use DropDown source.Though I set ‘displayMember’ to another field, displayMember seems to be ‘label’ field in source.
and I can see the display field data only when ‘label’ field is not exist.
Is it not bug? or is there explanation about it in api somewhere?Hello seonghye kim,
You can use jqxDataAdapter to simplify the data operations. In the following example the jqxDropDownList is bound to a local data source via jqxDataAdapter: http://jsfiddle.net/uuLjd0ys/.
Best Regards,
NadezhdajQWidgets team
http://www.jqwidgets.com/function getHierarchyTimeFrameDDL(iniValue) {
cellactionCount = 0;
//var TGTimeFrame = false;var ModelTimeFrame = function () {
this.items = ko.observableArray();
var me = this;
$.ajax({
datatype: ‘json’,
url: “Home/GetHierarchyTimeFrame”
}).done(function (data) {
// var jsonData = $.parseJSON(data);
// me.items(jsonData);
me.items(data);
});
};var modelTimeFrame = new ModelTimeFrame();
// prepare the data
var sourceTimeFrame =
{
datatype: “observablearray”,
datafields: [
{ name: ‘Description’ },
{ name: ‘lable’ }
],
id: ‘id’,
localdata: modelTimeFrame.items
};var daTimeFrame = new $.jqx.dataAdapter(sourceTimeFrame);
ko.applyBindings(modelTimeFrame);
// create widgets.$(“#TGTimeFrame”).jqxDropDownList({ source: daTimeFrame, displayMember: “Description”, promptText: “Select Year…”, autoDropDownHeight: true, valueMember: “lable”, autoOpen: “true”, width: 100, selectedIndex: 0, height: 25, theme: theme });
//$(“#TGTimeFrame”).jqxDropDownList(‘selectedIndex’, ‘2014’); //not working}//end of getHierarchyTimeFrameDDL
//$(“#TGTimeFrame”).bind(‘select’, function (event) {
//event.stopPropagation();
// ////if (cellactionCount == 0) {
// //$.ajaxSetup({ cache: false });
// ////if (event.args && !TGTimeFrame) {
// //// var args = event.args;
// //if (event.args) {
// // var item = event.args.item;
// // if (item != null) {
// // item = null;
// // //alert(“#TGTimeFrame”);
// // //alert($(“#TGTimeFrame”).jqxDropDownList(‘getSelectedItem’).label + ” label”);
// // //getHierarchyBJH($(“#TGTimeFrame”).jqxDropDownList(‘getSelectedItem’).value, 1);
// // //getHierarchyBJHDDL($(“#TGTimeFrame”).jqxDropDownList(‘getSelectedItem’).label);
// // getHierarchyBJHDDL(“InitialValue”);
// // event.preventDefault();
// // return false;
// // }
// //} // end of if (event.args) {
// ////TGTimeFrame = true;
// ////TGTimeFrame = false;
// ////cellactionCount = 1;
// ////} //end of if (cellactionCount == 0) {//});
public JsonResult GetHierarchyTimeFrame()
{try
{
ddlregualAll = new List<ddlRegual>();
string tablename = “tblHierarchyTimeFrameAll”;ds = opmFunction.GetHierarchyTimeFrame(10, tablename);
tmpTable1 = ds.Tables[tablename];if (generalutility.CheckDatasetReturnData(ds, tablename))
{
for (int i = 0; i < tmpTable1.Rows.Count; i++)
{
ddlregual = new ddlRegual();
ddlregual.Description = tmpTable1.Rows[i][“Descr”].ToString();
//ddlregual.lable = tmpTable1.Rows[i][“id”].ToString();
ddlregual.lable = tmpTable1.Rows[i][“Descr”].ToString();
ddlregualAll.Add(ddlregual);
}
return Json(ddlregualAll, JsonRequestBehavior.AllowGet);
}
else
{
return Json(null, JsonRequestBehavior.AllowGet);
}
}
catch
{
return Json(null, JsonRequestBehavior.AllowGet);
}
}email me if you have more question gagopa@yahoo.com
Hello Ray Choe,
Please, provide us with more information about your code in above post and remember to format your html/javascript code here by selecting it and pressing the
code
button in the toolbar.Best Regards,
NadezhdajQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.