Categories | Question details Back To List | ||
How do I make combo column not editable. Dear DHTMLX Team. I have an issue about combo with grid. Belows are my codes. ================================= // each rowId variable matches to single row's id var datas = [ {rowId: 1, no: 1, level: "A", admin: 0, birth: new Date()}, {rowId: 2, no: 2, level: "B", admin: 0, birth: new Date()}, {rowId: 3, no: 3, level: "C", admin: 0, birth: new Date()} ]; gridObj = new dhtmlXGridObject("gridDiv"); gridObj.setHeader("No, Level, Admin, Date of birth"); gridObj.setInitWidths("150,150,150,200"); gridObj.setColAlign("right,left,left,right"); gridObj.setColTypes("edn,co,ch,dhxCalendar"); gridObj.setColSorting("int,str,str,date"); // wrapper function to add Combo to grid's 2nd(index : 1) column. GridManager.setComboColumn(gridObj, "level", [{value: "A", label:"level A"}, {value: "B", label: "level B"}, {value: "C", label: "level C"}]); gridObj.init(); // wrapper function to conver data variable to grid's dataset. GridManager.convert2GridData(gridObj, datas); ================================= This code works fine. then, I want to make 2nd column of 1st row not to editable. But, below code works wiered. ================================= // column gone to not editable, but column display "A" not "level A". gridObj.setCellExcellType(1, 1, "ro"); // column stil draw combo and selectable and also value modified -> not readonly! gridObj.setCellExcellType(1, 1, "coro"); ================================= How do I make combo column "not editable"? Answer posted by Support on Dec 29, 2008 16:46 When you changing column type , the new cell will get the value of old cell (A) not the label (level A) You can add next code to the init of the grid var comboflag=true; gridObj.attachEvent("onEditCell",function(stage,id,ind){ if (!comboflag && ind==1) return false; }); now, in any moment of time you can change the value of comboflag var to false and disable edit operations for second column ( which is a combo in your case ) Answer posted by Pumsuk Cho on Dec 29, 2008 22:49 Dear DHTMLX Team. Thanks for fast reply. I've found another way to solv the problem. Changing value of combo cell disabled via gridObj.cells(1, 1).setDisabled(true); this works perfect!. (this trick inspired from this article http://www.dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=5784&ssr=yes&s=radio) And... I still have a question to you. In some document, exCell type "coro" means combo column with read only property. I understand "read only" that column can not be editable. After some test, "read only" means combo option can not be added or removed. This synonym make me confused (may with my poor english skill). Changing column type to "ro" or "ron" makes column not editable. Changing to"coro" makes column still editable. This looks wierd to me. :) Answer posted by Support on Dec 30, 2008 12:46 The names can be a bit confusing, the original idea is co - means combo-box, select list with edit possitibilit coro - select-box, combo without edit possibility, but value still can be changed to one of allowed If you need to have fully readonly type you can use "ro". The only place where problem may occurs - switching from the co|coro column type to different one, because co|coro column type separate data on label and value, while other column types use only value. |