jQWidgets Forums
jQuery UI Widgets › Forums › Grid › coloumn index and coloumn text in create editor call back
Tagged: grid column
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 1 month ago.
-
Author
-
hi,
I want to get the value of coloumn index and coloumn text in createeditor call back function. is there any provision to get that as i have seen no such parameter in createeditor function defined in documentation. pls help..
Thanks.
Hi Nagoor,
createeditor is a column property which can point to a custom callback function. As it is a column property, you should already know the column’s text and datafield.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/hi peter,
i agree with you. in my case, i am populating grid coloumns and datafields dynamically for which i am getting the data from the server. so, we are not sure about the coloumn text and datafield as they will be populated in loop. and editor will be called onclicking the cell, so at that time i need to find the text in coloumn header so that i can write logic there based on the coloumn name as per my requirement. here is the sample..
var colDataFieldArray =[“userName”,”emailId”,”company”,”Flag”];//This is the array which contain Dynamic column datafields first set
for(var i=0;i<(colDataFieldArray.length);i++){
var colStr = $.trim(colDataFieldArray[i]);
gridColumns.push({ text:$.trim(colDataFieldArray[i]), dataField: colStr, editable:false, align : ‘center’, cellsalign:’center’,width: 150});
dataFieldColumns.push({name:colStr, type: ‘string’});
}gridColumns.push({text: “User Id”, dataField: “userId”, hidden:true, cellsalign:’center’});
dataFieldColumns.push({name: “userId”, type: ‘string’});// coloumns for second set to perform editor operation
for(var i=0;i<(serviceArray.length);i++){
var colStr = $.trim(serviceArray[i]);gridColumns.push({ text:$.trim(serviceArray[i]), dataField: $.trim(serviceArray[i]),align : ‘center’, editable:true,cellsalign:’center’, width: 150,columntype: ‘dropdownlist’,
createeditor: function (row, cellvalue, editor, celltext) {
var list = [cellvalue,”none”]; // here in place of cell value i want the column header texteditor.jqxDropDownList({ autoDropDownHeight: true, source: list, promptText: “Please Choose:” });
},geteditorvalue: function (row, cellvalue, editor) {
// return the editor’s value.
return editor.val();
}
});dataFieldColumns.push({name: $.trim(serviceArray[i]), type: ‘string’});
}here, i am populating two sets of coloumns as you can see. for the secong set i v=have to perform editor operation. if i try to get the datafield value , obviously its showing undefined, so i suggest you can add one more parameter so that to get the coloumn header text or value.
hope you understand my problem.Thanks in advance
Hi Nagoor,
In your case, instead of using for(var i=0;i< (serviceArray.length);i++){, you can use $.each, then create variable: var text = $.trim(serviceArray[i]); and each time the createeditor is called, use that variable as it would be in the same context as createeditor. Best Regards, Peter Stoev jQWidgets Team http://www.jqwidgets.com/
-
AuthorPosts
You must be logged in to reply to this topic.