Hi there,
I'm trying to implement batch edit in my RadGrid and got one problem I cannot resolve due to lack of info.
I call RadGrid.get_batchEditingManager().addNewRecord , in my radgrid I've got several template columns with radcombos there,
there are related and everything work perfect because I can use $telerik.findControl to refer any other cell's radcomboboxes control
while changing index of the current combo cell editing. Eventually, I have to change some Label control text value basing on chosen
selected Item in another combobox of another cell. But how should I refer from some given editing cell to another template column's
which has ItemTemplate Label control only in order to change label's text value ?
I tried $telerik.findControl($find("<%= MyGrid.ClientID %>").get_element(), "myLabel") but it always gets null instead of label object.
Thanks in advance,
Nik
I'm trying to implement batch edit in my RadGrid and got one problem I cannot resolve due to lack of info.
I call RadGrid.get_batchEditingManager().addNewRecord , in my radgrid I've got several template columns with radcombos there,
there are related and everything work perfect because I can use $telerik.findControl to refer any other cell's radcomboboxes control
while changing index of the current combo cell editing. Eventually, I have to change some Label control text value basing on chosen
selected Item in another combobox of another cell. But how should I refer from some given editing cell to another template column's
which has ItemTemplate Label control only in order to change label's text value ?
I tried $telerik.findControl($find("<%= MyGrid.ClientID %>").get_element(), "myLabel") but it always gets null instead of label object.
Thanks in advance,
Nik
8 Answers, 1 is accepted
0
Hi Nik,
I am not quite sure that I fully understand the scenario but if I am correct you want to access a control which is placed inside an ItemTemplate, for the newly added grid row. Now it is important to know that when addNewRecord is called RadGrid will only append a new tr element to its table and will not initialize any server controls(such as an ASP Label) as this action is performed solely on the client. That said it is expected to not be able to obtain a reference to the label. However if you are trying to access the label in the ItemTemplate of an already existing row(meaning a row which is displayed initially when the grid loads) you can try something like this.
JavaScript:
The above logic will first obtain a reference to the row in which the edited cell is position and from there access the label by id.
Regards,
Angel Petrov
Telerik
I am not quite sure that I fully understand the scenario but if I am correct you want to access a control which is placed inside an ItemTemplate, for the newly added grid row. Now it is important to know that when addNewRecord is called RadGrid will only append a new tr element to its table and will not initialize any server controls(such as an ASP Label) as this action is performed solely on the client. That said it is expected to not be able to obtain a reference to the label. However if you are trying to access the label in the ItemTemplate of an already existing row(meaning a row which is displayed initially when the grid loads) you can try something like this.
JavaScript:
function
clientSelectedIndexChanged(sender, args) {
var
row = Telerik.Web.UI.Grid.GetFirstParentByTagName(sender.get_element(),
"tr"
),
label = $telerik.findElement(row,
"LabelID"
);
}
Regards,
Angel Petrov
Telerik
DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.
0

Nik
Top achievements
Rank 1
answered on 24 Mar 2014, 07:07 PM
Thanks for the advise, I found a solution on my question.
I've got another one: I have GridCheckBoxColumn with DataType="System.Boolean" . In batch edit if one changes checkbox there, it's going in a common way in the opened editor , but when the editor is closed, I see "true" or "false" as the values of cell there instead of checkbox controls. How should I fix that up ? Thanks in advance.
I've got another one: I have GridCheckBoxColumn with DataType="System.Boolean" . In batch edit if one changes checkbox there, it's going in a common way in the opened editor , but when the editor is closed, I see "true" or "false" as the values of cell there instead of checkbox controls. How should I fix that up ? Thanks in advance.
0
Hello Nik,
As I mentioned in my previous post RadGrid will only append a new tr element when the Add new record button is clicked. Since the GridCheckBoxColumn uses the ASP CheckBox in read mode it is expected for a check box to not appear for the new rows since it can not be initialized.
In order to workaround this problem you can use a template column instead and manually add a check box for the new rows using JavaScript. For that purpose you can subscribe to the OnRowCreated event and execute logic similar to the one provided below.
JavaScript:
From there you need to attach a click event handler and force the opening of the cell for edit once the newly added check box is clicked.
JavaScript:
By following the above suggested approach you should be able to make things work.
Regards,
Angel Petrov
Telerik
As I mentioned in my previous post RadGrid will only append a new tr element when the Add new record button is clicked. Since the GridCheckBoxColumn uses the ASP CheckBox in read mode it is expected for a check box to not appear for the new rows since it can not be initialized.
In order to workaround this problem you can use a template column instead and manually add a check box for the new rows using JavaScript. For that purpose you can subscribe to the OnRowCreated event and execute logic similar to the one provided below.
JavaScript:
function
rowCreated(sedner,args) {
if
(args.get_id().indexOf(
"-"
) != -1) {
var
cell = args.get_item().get_cell(
"ColumnName"
);
var
element = document.createElement(
"input"
);
element.setAttribute(
"type"
,
"checkbox"
);
cell.appendChild(element);
}
}
JavaScript:
function
rowCreated(sedner,args) {
if
(args.get_id().indexOf(
"-"
) != -1) {
var
cell = args.get_item().get_cell(
"ColumnName"
);
var
element = document.createElement(
"input"
);
element.setAttribute(
"type"
,
"checkbox"
);
element.setAttribute(
"onclick"
,
"openCellForEdit(this)"
);
cell.appendChild(element);
}
}
function
openCellForEdit(sender) {
var
cell = Telerik.Web.UI.Grid.GetFirstParentByTagName(sender,
"td"
),
grid = $find(
'<%=RadGrid1.ClientID%>'
),
manager = grid.get_batchEditingManager();
manager.openCellForEdit(cell);
}
By following the above suggested approach you should be able to make things work.
Regards,
Angel Petrov
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.
0

Nik
Top achievements
Rank 1
answered on 31 Mar 2014, 02:41 PM
Hello Angel,
Thanks a lot for the solution.
I've got yet another question with the same radGrid in batch mode: in all radComboBoxes where I do not use DataSourceID defined at the design time, and instead I'm using OnItemsRequested, I always get empty values for those corresponding cells values in OnBatchEditCommand, both on Update or Insert command types. In ItemsRequested server method - I fill combos with List<string>. A chosen value on client is represented correctly, but no values are passed to the server side. And again, for those columns where combos are having DataSourceIDs declaratively - values are passed ok.
Please advise how to solve that.
Thanks in advance.
Thanks a lot for the solution.
I've got yet another question with the same radGrid in batch mode: in all radComboBoxes where I do not use DataSourceID defined at the design time, and instead I'm using OnItemsRequested, I always get empty values for those corresponding cells values in OnBatchEditCommand, both on Update or Insert command types. In ItemsRequested server method - I fill combos with List<string>. A chosen value on client is represented correctly, but no values are passed to the server side. And again, for those columns where combos are having DataSourceIDs declaratively - values are passed ok.
Please advise how to solve that.
Thanks in advance.
0
Hi Nik,
I have to say that this is not an expected behavior. Could you please share with us the markup and code-behind of the page so we could examine the exact implementation? Once we have a better view over the exact setup we will be able to narrow down the reasons that might cause this problem.
Regards,
Angel Petrov
Telerik
I have to say that this is not an expected behavior. Could you please share with us the markup and code-behind of the page so we could examine the exact implementation? Once we have a better view over the exact setup we will be able to narrow down the reasons that might cause this problem.
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Nik
Top achievements
Rank 1
answered on 03 Apr 2014, 08:59 PM
Hello Angel,
Thanks a lot for you feedback and time, but I've sorted it out already - there was my fault - I just did not set DataValueField.
But I'm still cannot realize how to do one more thing. I'd appreciate if you could reply me ASAP, again, many thanks in advance.
Again, the same radGrid with Batch edit mode, EditType="Cell".
I have a radComboBox in EditItemTemplate of a TemplateColumn. This radComboBox with checkboxes in turn has its own ItemTemplate which is a table with Label and DropDownList controls (with integer figures in it) in 2 respective columns of the table. Could you please give me an example on how to pass in OnBatchEditCommand server's method the data about which combo items are checked, namely, if an item is checked I'd like to get somewhat like label's.text + corresponding integer number selected value of a ddList (like e.g. resulted string "someText"+"1") ? In another words, I'd like to get those selected items data in a corresponding string value of a Hashtable newValues. I could use my web service method, but it would be really more flexible to get it in Hashtable newValues while making Update or Insert.
Thanks a lot for you feedback and time, but I've sorted it out already - there was my fault - I just did not set DataValueField.
But I'm still cannot realize how to do one more thing. I'd appreciate if you could reply me ASAP, again, many thanks in advance.
Again, the same radGrid with Batch edit mode, EditType="Cell".
I have a radComboBox in EditItemTemplate of a TemplateColumn. This radComboBox with checkboxes in turn has its own ItemTemplate which is a table with Label and DropDownList controls (with integer figures in it) in 2 respective columns of the table. Could you please give me an example on how to pass in OnBatchEditCommand server's method the data about which combo items are checked, namely, if an item is checked I'd like to get somewhat like label's.text + corresponding integer number selected value of a ddList (like e.g. resulted string "someText"+"1") ? In another words, I'd like to get those selected items data in a corresponding string value of a Hashtable newValues. I could use my web service method, but it would be really more flexible to get it in Hashtable newValues while making Update or Insert.
0
Hello Nik,
In order to implement the desired functionality you should subscribe to the four batch edit events(OnBatchEditGetCellValue, OnBatchEditSetEditorValue, OnBatchEditGetEditorValue and OnBatchEditSetCellValue) and handle things manually like demonstrated in this help article. The main-point here is passing the desired value to the arguments in the OnBatchEditGetEditor event thus making it available on the server when the Save changes button is clicked. As for accessing the controls in the combo ItemTemplate in order to extract their values I recommend that you examine this article which demonstrates how it can be achieved.
Regards,
Angel Petrov
Telerik
In order to implement the desired functionality you should subscribe to the four batch edit events(OnBatchEditGetCellValue, OnBatchEditSetEditorValue, OnBatchEditGetEditorValue and OnBatchEditSetCellValue) and handle things manually like demonstrated in this help article. The main-point here is passing the desired value to the arguments in the OnBatchEditGetEditor event thus making it available on the server when the Save changes button is clicked. As for accessing the controls in the combo ItemTemplate in order to extract their values I recommend that you examine this article which demonstrates how it can be achieved.
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Nik
Top achievements
Rank 1
answered on 11 Apr 2014, 01:24 PM
Angel,
Of course I checked many times the universally-addressed-page http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html , it's not helpful on my problem. My question was to show an example on what I needed specifically. Ok, I'll try and if that would not work out, I will ask more specific questions one-by-one :-)
Of course I checked many times the universally-addressed-page http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html , it's not helpful on my problem. My question was to show an example on what I needed specifically. Ok, I'll try and if that would not work out, I will ask more specific questions one-by-one :-)