11 Answers, 1 is accepted
You can get the current row being edited, by using the "edit" event argument and its container property like this:
However there is no built-in functionality to get the name of the column that is currently edited. You can check for the focused input and get its name attribute that is equal to the field name, as a possible solution.
As you are talking about a custom validation of the grid's cells, I would suggest you to use the built-in validator. Using it you can perform custom validation for each of the columns, based on their type or other properties. Please check this forum topic to see a discussion about a possible implementation:
You can use the jQuery .blur() event handler to execute the validation when the element being edited loses focus. You can bind to the edit event of the grid, find all the inputs and attach the handler.
For your convenience here is a jsBin example which demonstrates a possible implementation.
"However there is no built-in functionality to get the name of the column that is currently edited. You can check for the focused input and get its name attribute that is equal to the field name, as a possible solution."
Your collague Alexander has a solution for this, see his post: http://www.kendoui.com/forums/permalink/cltSVQhahkqVx2ehrNdGfA
I have suggested a way to achieve this functionality. It is not built-in but it gets the job done, the solution provided by my colleague does not depend on built-in method or property that gives information about the currently edited column, but it also gets the job done. There are a few way to achieve certain functionality, based on your project and current approach.
I am really glad to hear that you liked the solution that was provided to you.
I assume that the question is related to a hierarchy scenario, where there is a detail/child grid. Since it is completely separate grid widget same approach could be as well. The only difference that the grid instance should point to the child/detail grid instance instead.
Like Sharon asked in the previous question, What about the sub columns(defined as columns.columns). How to find the field or title name of that column? the suggested method is working for direct columns, but for the sub columns, it is throwing an error.
In general the Kendo UI DataSource is designed to work with flat data, but since the columns field returns an array it is possible to access an object in nested array.
Could you please share a sample dojo example that replicates the problem?Regards,
Sorry for the late response.
please find the requested dojo.
I used the same method suggested in this post to find the column name. But in this dojo I have sub-columns. So, if you try to find the column 3 name in the attached dojo, it is throwing an error(Please check console) because it is treating the sub column 2 as column 3.
So, please help me out to find the correct column 3 the attached dojo.
I am pasting the answer from the support ticket on the same topic in case anyone from the community encounters the same problem.
To get the field of the relevant column, I would suggest getting the name attribute of the input as it matches the field name due to the data binding.
For example, the code could look like:
For a runnable example, check the modified Dojo: