i has a iggrid that has updatting feature and that has 1 editor. each record will show editor type difference from each other. i want to change from text editor to combobox editor and gainsay
who can help me?
have anyone with other solution for this problem?
Hello Cuong,
Thank you for your patience while I was looking into this matter for you.
Since editor type could not be changed run time my suggestion is to create a custom editor provider which contains both the text editor and the combo and hide one of them based on the cell value. Once you create the custom editor the setValue and getValue methods for this editor should be defined in order to correctly set and get the cell value according to the type of editor currently shown.For example:
//creating custom editor provider $.ig.EditorProviderComboTextbox = $.ig.EditorProvider.extend({ createEditor: function (callbacks, key, editorOptions, tabIndex, format, element) { element = $("<div id='templateContainer2'></div>"); element.append('<div id="textEditor"></div>'); element.append('<div id="combo" />'); return element; }, getValue: function () { if (this.currentEditor.attr("id") == "textEditor") return this.currentEditor.igTextEditor("value") else return this.currentEditor.igCombo("value"); }, setValue: function (val) { this.combo = $("#combo"); this.txtEditor = $("#textEditor"); if (val === "combo") { this.txtEditor.hide(); this.combo.show(); this.currentEditor = this.combo; } else { this.txtEditor.show(); this.combo.hide(); this.currentEditor = this.txtEditor; } createControls(val); }, attachErrorEvents: function () { } }); function createControls(val) { $("#combo").igCombo({ allowCustomValues:true, dataSource: coboData, textKey: "Text", valueKey: "Text", width: "100%" }); $("#combo").igCombo("value", val); $("#textEditor").igTextEditor({ width: "100%", placeHolder: "Enter Text", value: val }); }
//creating custom editor provider $.ig.EditorProviderComboTextbox = $.ig.EditorProvider.extend({ createEditor: function (callbacks, key, editorOptions, tabIndex, format, element) { element = $("<div id='templateContainer2'></div>"); element.append('<div id="textEditor"></div>'); element.append('<div id="combo" />'); return element; }, getValue: function () {
if (this.currentEditor.attr("id") == "textEditor") return this.currentEditor.igTextEditor("value") else return this.currentEditor.igCombo("value"); }, setValue: function (val) { this.combo = $("#combo"); this.txtEditor = $("#textEditor"); if (val === "combo") { this.txtEditor.hide(); this.combo.show(); this.currentEditor = this.combo; } else { this.txtEditor.show(); this.combo.hide(); this.currentEditor = this.txtEditor; } createControls(val); },
attachErrorEvents: function () { } });
function createControls(val) { $("#combo").igCombo({ allowCustomValues:true, dataSource: coboData, textKey: "Text", valueKey: "Text", width: "100%" }); $("#combo").igCombo("value", val); $("#textEditor").igTextEditor({ width: "100%", placeHolder: "Enter Text", value: val }); }
I am also attaching a sample illustrating my suggestion for your reference.
Please keep in mind that since the behavior that you would like to achieve is not supported out of the box this is a custom implementation for achieving your requirement.
I hope you find my suggestion helpful.
Hi Vasya!
Thanks you very much for you spirit!
Your code work fine with my case! it's very helpful
but
- can you show me how to show done button by standar function of infragistics? because button 'done' did not showed after i edited this field(it is disabled)
- and how can i access into any column of current editing row at setvalue function
setValue: function (val) {
//i need to get other column of current editing row this.combo = $("#combo"); this.txtEditor = $("#textEditor"); createControls(val); if (val === "combo") { this.txtEditor.hide(); this.combo.show(); this.currentEditor = this.combo; } else { this.txtEditor.show(); this.combo.hide(); this.currentEditor = this.txtEditor; } }
i'm still waiting for your answer
thanks again!