jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Get dropdownlist control from grid and disable items
Tagged: disable, disableItem, DropDownList, editor, grid, item, jqxDropDownList, jqxgrid
This topic contains 3 replies, has 2 voices, and was last updated by fbrem 11 years, 4 months ago.
-
Author
-
Hi there,
is ist possible to get a dropdownlist control from a grid cell and disable items of the dropdownlist?
createeditor: function (row, value, editor) { editor.jqxDropDownList({ source: languagesDataAdapter, displayMember: 'name', valueMember: 'code' }); editor.bind('select', function (event) { var args = event.args; if (args) { item = args.item; if (item != null) { var rows = $('#jqxgridpop').jqxGrid('getboundrows'); for (var i = 0; i < rows.length; i++) { var cell = $('#jqxgridpop').jqxGrid('getcell', i, 'languageddl'); //!! Get dropdownlist, disable items }; } } }); },
Hello fbrem,
From your code I did not understand the condition to disable a particular item, but here is the general idea to do so:
createeditor: function (row, value, editor) { editor.jqxDropDownList({ source: languagesDataAdapter, displayMember: 'name', valueMember: 'code' }); var item = editor.jqxDropDownList('getItemByValue', "Example value"); editor.jqxDropDownList('disableItem', item); }
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
thanks, but that’s not what i am looking for. I have a grid with a dropdown column. Now, if in a row a dropdown item is selected, this dropdown item should be deactivated in all following rows.
So, i have to get all rows:
var rows = $('#jqxgridpop').jqxGrid('getboundrows');
then get all cells containing the dropdown
for (var i = 0; i < rows.length; i++) { var cell = $('#jqxgridpop').jqxGrid('getcell', i, 'languageddl');
and then, whit some magic, get the dropdowncontrol from the cell to disable the item. This is where i’m stuck.. I think, it is not possible to get a dropdown control from a single grid cell…
Hi Dimitar,
my fault, you are absolutely right, your solution is the correct way to achieve this, at the open event of a dropdown:
editor.bind('open', function (event) { var rows = $('#jqxgridpop').jqxGrid('getboundrows'); for (var i = 0; i < rows.length; i++) { var value = $('#jqxgridpop').jqxGrid('getcellvalue', i, "languageCode"); var item = editor.jqxDropDownList('getItemByValue', value); editor.jqxDropDownList('disableItem', item); }; });
Thanks alot!
-
AuthorPosts
You must be logged in to reply to this topic.