jQWidgets Forums
jQuery UI Widgets › Forums › Editors › Input, Password Input, TextArea, ColorPicker, Rating, TagCloud, Loader › jqxInput – json and select event
Tagged: jqxinput
This topic contains 4 replies, has 2 voices, and was last updated by kotaskam 11 years, 3 months ago.
-
Author
-
Hello,
I am struggling with jqxInput and select handling of its select event.
I used a code below to make an autocomplete function – it works – but when I want to get information about selected item I have a problem.The code:
<asp:TextBox ID="edUserName" runat="server" Width="250px" CssClass="editbox"></asp:TextBox> $('#<%=edUserName.ClientID %>').jqxInput({displayMember: "KDO", valueMember: "BARVA", placeHolder: "Enter a Customer name", height: 23, width: 200, minLength: 1, theme: 'ui-redmond', source: function (query, response) { var dataAdapter = new $.jqx.dataAdapter ( { datatype: "json", datafields: [ { name: 'KDO', type: 'string' }, { name: 'BARVA', type: 'string' }, { name: 'FIRMA', type: 'string' } ], url: 'GetCustomers.aspx' }, { autoBind: true, formatData: function (data) { data.query = query; return data; }, loadComplete: function (data) { if (data.length > 0) { response($.map(data, function (item) { return item.KDO; })); } } } ); } }); $('#<%=edUserName.ClientID %>').on('select', function (event) { if (event.args) { var item = event.args.item; if (item) { var barva = new $.jqx.color({ hex: int2hex(255) }); $("#colorPicker").jqxColorPicker('setColor', '#' + int2hex(255)); $("#dropDownButton").jqxDropDownButton('setContent', getTextElementByColor(barva)); } } });
When I debug a select event I still have no item object. I get only event.args object with members label and value. There is no event.args.item object.
Thank you.
Best regards,
Milan Kotaska
Hi Milan,
May be you don’t use the latest version of jQWidgets and there’s no such event.args.item on your side.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I upgraded source files to 1.11.0 version and it seems that event.args.item is defined now.
The item object has a label and value property (member variables) as expected but they have both the same value.
I still do not know why. Could it be caused by definition of dataadaprer variable ?Thanx.
Best regards,
Milan Kotaska
Hi Milan,
It does not matter whether you use jQuery 1.11 or jQuery 1.7. It matters whether you use the latest version of jQWidgets. As far as I see, in your implementation your return only Text, not an object which has Label and Value i.e actually, your code:
if (data.length > 0) { response($.map(data, function (item) { return item.KDO; })); }
looks strange and I think this part should be removed.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you a lot you pointing me for a problem solution. It works now.
Best regards,
Milan Kotaska
-
AuthorPosts
You must be logged in to reply to this topic.