Hello again, I asked for help with my radgrid programming in this topic here. This time, I have a related issue in this javascript function with the update part of it.
For reference, here's the function:
The part of code that updates items is made bold.
While this code in normal situation just works fine and updates my rows when pressing enter, I found a specific situation where it wouldn't work. In one detailview of my radgrid, I put some of the columns of that detailview in read only mode(in the item created event of the radgrid), so that users can only edit the specific fields of a row. It's in this detailview that the javascript generates and error when trying to use this update function. It will generate the error "object expected" on this line:
if ($(el).parents("tr").attr("id") && $(el).parents("tr").attr("id") != "")
Further investigation reveals that it's this part: $(el) that generates the error.
After this, I tried playing around with putting columns in read only mode and using this function. I discovered that specifically, if the -first- column of a row is in read only mode when trying to use this code, it will generate an error. With any other column of that row in readonly mode it would work just fine, it's just that first column that generates the "object expected" error.
Do you have any idea how I could fix this issue without putting the first column of my detailview in edit mode?
For reference, here's the function:
| function KeyPressEnter(sender, args) |
| { |
| var $ = $telerik.$; |
| if (args.get_keyCode() != 13) |
| return; |
| var el = Telerik.Web.UI.Grid.GetCurrentElement(args.get_domEvent()); |
| if (el.tagName.toLowerCase() != 'input' && el.tagName.toLowerCase() != 'textarea') return; |
| if (sender.get_masterTableView().get_isItemInserted()) |
| { |
| var evt = args.get_domEvent(); |
| //if (evt.stopPropagation) evt.stopPropagation(); |
| if (evt.preventDefault) evt.preventDefault(); |
| sender.get_masterTableView().insertItem(); |
| return false; |
| } |
| var detailtables = sender.get_detailTables(); |
| if (detailtables.length > 0) { |
| for (var i = 0; i < detailtables.length; i++){ |
| if (detailtables[i].get_isItemInserted()) { |
| var evt = args.get_domEvent(); |
| if (evt.preventDefault) evt.preventDefault(); |
| detailtables[i].insertItem(); |
| return false; |
| } |
| } |
| } |
| if ($(el).parents("tr").attr("id") && $(el).parents("tr").attr("id") != "") |
| { |
| var evt = args.get_domEvent(); |
| //if (evt.stopPropagation) evt.stopPropagation(); |
| if (evt.preventDefault) evt.preventDefault(); |
| sender.get_masterTableView().updateItem($(el).parents("tr")[0]); |
| return false; |
| } |
| } |
While this code in normal situation just works fine and updates my rows when pressing enter, I found a specific situation where it wouldn't work. In one detailview of my radgrid, I put some of the columns of that detailview in read only mode(in the item created event of the radgrid), so that users can only edit the specific fields of a row. It's in this detailview that the javascript generates and error when trying to use this update function. It will generate the error "object expected" on this line:
if ($(el).parents("tr").attr("id") && $(el).parents("tr").attr("id") != "")
Further investigation reveals that it's this part: $(el) that generates the error.
After this, I tried playing around with putting columns in read only mode and using this function. I discovered that specifically, if the -first- column of a row is in read only mode when trying to use this code, it will generate an error. With any other column of that row in readonly mode it would work just fine, it's just that first column that generates the "object expected" error.
Do you have any idea how I could fix this issue without putting the first column of my detailview in edit mode?