jQWidgets Forums
Forum Replies Created
-
Author
-
March 10, 2014 at 7:32 am in reply to: DropDown in Grid, disabling a DropDown Item leads to strange behavior DropDown in Grid, disabling a DropDown Item leads to strange behavior #50751
Hi Dimitar, here as requestet the full code for the grid..
var languages = [{ "id": "0", "code": 0, "name": "All browser languages" }, { "id": "1", "code": 1031, "name": "German" }, { "id": "2", "code": 1033, "name": "English" }, { "id": "3", "code": 1034, "name": "Spanish" }, { "id": "4", "code": 1036, "name": "French" }, { "id": "5", "code": 1040, "name": "Italian" }, { "id": "6", "code": 1045, "name": "Polish" }, { "id": "7", "code": 1046, "name": "Portuguese" }]; var languagessource = { datatype: "json", datafields: [ { name: 'code', type: 'int' }, { name: 'name', type: 'string' } ], id: 'id', cache: true, localdata: languages }; var languagesDataAdapter = new $.jqx.dataAdapter(languagessource, { formatData: function (data) { return {}; }, contentType: 'application/json; charset=utf-8', loadError: function (xhr, status, error) { //alert(error); }, autoBind: true }); $("#jqxgridpop").jqxGrid({ width: '100%', autoheight: false, height: 300, editable: true, selectionmode: 'singlerow', editmode: 'click', columns: [ { text: 'URL:', dataField: 'urlNew', width: '49%' }, { text: 'Browser Language', columntype: 'dropdownlist', dataField: 'languageCode', displayfield: 'languageddl', width: '20%', autoOpen: 'false', autoDropDownHeight: true, createeditor: function (row, value, editor) { editor.jqxDropDownList({ source: languagesDataAdapter, displayMember: 'name', valueMember: 'code', placeHolder:"" }); editor.bind('open', function (event) { //first, enable all items var items = editor.jqxDropDownList('getItems'); for (var i = 0; i < items.length; i++) { editor.jqxDropDownList('enableItem', items[i]); }; //second, disable items by value of rows 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); }; }); } }, { text: 'Status', dataField: 'status', width: '8%', cellsalign: 'right', columntype: 'checkbox', filtertype: 'bool'}, { text: 'Fallback', dataField: 'defaultChild', width: '8%', cellsalign: 'right', columntype: 'checkbox', filtertype: 'bool'} ], ready: function () { }, showstatusbar: true, statusbarheight: 40, renderstatusbar: function (statusbar) { // appends buttons to the status bar. var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); var addButton = $("<div style='float: left; margin-left: 5px;'><img id='popgridadd' style='position: relative; margin-top: 2px;' src='add.png'/></div>"); var deleteButton = $("<div style='float: left; margin-left: 5px;'><img id='popgriddelete' style='position: relative; margin-top: 2px;' src='trash.png'/></div>"); container.append(addButton); container.append(deleteButton); statusbar.append(container); addButton.jqxButton({ width: 20, height: 20 }); deleteButton.jqxButton({ width: 20, height: 20 }); // add new row. addButton.click(function (event) { if (addButton.jqxButton('disabled') == false) { addChildRow(); }; }); deleteButton.click(function (event) { var id = $("#jqxgridpop").jqxGrid('getrowid', selectedrowindex); var commit = $("#jqxgridpop").jqxGrid('deleterow', id); }); }, ready: function () { } });
March 6, 2014 at 11:16 am in reply to: Get dropdownlist control from grid and disable items Get dropdownlist control from grid and disable items #50590Hi 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!
March 6, 2014 at 9:21 am in reply to: Get dropdownlist control from grid and disable items Get dropdownlist control from grid and disable items #50578Hi 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…
March 5, 2014 at 2:37 pm in reply to: Disable/hide button on RenderToolbar Disable/hide button on RenderToolbar #50527Hi there,
in my case i solved this by adding an image to the button with a fixed id, and then getting the button via jquery…
//in grid, when creating the button ... renderstatusbar: function (statusbar) { // appends buttons to the status bar. var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); var addButton = $("<div style='float: left; margin-left: 5px;'><img id='<strong>popgridadd</strong>' style='position: relative; margin-top: 2px;' src='/scripts/img/add.png'/></div>"); container.append(addButton); //on event ... $("#popgridadd").parent().jqxButton({ disabled: true });
December 12, 2013 at 8:17 am in reply to: Beginner: Grid, Dataadapter and Paging Beginner: Grid, Dataadapter and Paging #46392I got an answer to this question on stackoverflow (http://stackoverflow.com/questions/20537014/jqwidgets-jqxgrid-dataadapter-and-paging) In the dataadapter include:
formatData: function (data) { return {}; },
and in the source:
cache: true
December 11, 2013 at 2:23 pm in reply to: Beginner: Grid, Dataadapter and Paging Beginner: Grid, Dataadapter and Paging #46346Hi Peter,
i don’t understand your question. I don’t get any data, the GET-call fails because of the included parameters
?filterscount=0&groupscount=0&pagenum=0&pagesize=10&recordstartindex=0&recordendindex=18&_=1386768031615
.How do i get rid of them?
-
AuthorPosts