This is a migrated thread and some comments may be shown as answers.

RadGrid within DataForm

2 Answers 211 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 18 May 2016, 10:35 AM

Hi,

I have a Radgrid within a dataform. When the user click edit on the Dataform I can get the Radgrid to display in Batch edit mode.

But on pressing the Update button on the Dataform, how do I get the values of the edited grid in code behind.

I already use the _ItemUpdating event for the Dataform, and thought I would be able to see the values of the edited grid with EditItems

But it seems not.

Many Thanks for any help

Mark

2 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 19 May 2016, 09:03 AM
In a very roundabout way I have managed to get it to work.

The RadGrid is sitting in the EditItemTemplate of a RadDataForm. And when the page displays the RadGrid is in Batch Edit mode  <MasterTableView EditMode="Batch" ></MasterTableView>

Ideally I would like to extract all the values of the RadGrid when the user clicks the RadDataForm Update button within the RadDataForm_ItemUpdating event.
But this doesn’t seem possible.
So I have used OnClientClicked=" SaveSeasonCosts " on the RadDataForm Update button, this calls a javascript function to mimic the update of the grid.

Function SaveSeasonCosts(Sender, args) {

  var id = Sender.get_element().id;
var GetGridClientID = $get(id).getAttribute("GID");

var grid = $find(GetGridClientID);
 grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());

}


Which in turn fires the _BatchEditCommand event of the RadGrid where I can get to the values.

So is this the way to do this? Other than javascript is there no other way to invoke an update of the grid when the RadDataForm updates?

Many Thanks

Mark
0
Eyup
Telerik team
answered on 23 May 2016, 07:54 AM
Hello Mark,

Yes, you are correct. Essentially, Batch editing mode is different than other modes. You can find a detailed explanation in the following section:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-batch-edit-mode


You need to use the Batch client-side API to execute your logic:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/client-side-api

For using an external button to save the records, you can check the following post:
http://www.telerik.com/forums/how-to-fire-the-updateedited-method-from-an-outside-button#5Af7aU0fFEa0UKS5HOhyjA

The crucial key requirement here is that the postback should be initiated by the Batch client-side API commands. I hope the clarification was helpful.


Regards,
Eyup
Telerik
Tags
DataForm
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or