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

Paging with Bulk Edit

7 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jon
Top achievements
Rank 1
jon asked on 30 Jun 2010, 08:19 PM

My RadGrid is setup to perform bulk edits, and that is all working well.  So this works great:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) {

 

 

if (e.CommandName == "UpdateAll") {

 

    SaveTableData(e);

}

I'm preforming the Update/Insert like this:
foreach (GridEditableItem editedItem in RadGrid1.EditItems) {

 

 

    Hashtable newValues = new Hashtable();

 

 

    //The GridTableView will fill the values from all editable columns in the hash

 

 

 

    e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
}

 

 

 

However, when i add Paging to the mix, then the updates/inserts of the data are lost.  That is, if the user enters in all their data, and then forgets to Save their data and instead moves to the next page of the bulk edit table, then the data they entered is lost.

So I aded this function to try to fix that:
protected void RadGrid1_PageIndexChanged(object source, GridCommandEventArgs e) {

 

    SaveTableData(e);

}
But this 'e' does not have the user's new data that they entered in.
Why does the 'e' not have the new values?

7 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 06 Jul 2010, 06:25 AM
Hello John,

The paging command event arguments object has the purpose of storing information about the paging operation, such as new page index for example, and is not related to editing. If you need to save the information, you should traverse the edit items, extract their new values, remember on which page those items are, and their item indexes too (so that you be able to put them back into edit mode).

Hope this helps.

Greetings,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jon
Top achievements
Rank 1
answered on 06 Jul 2010, 03:30 PM
I get that in theory, but am having trouble actually getting it to work.  Can you point me to an example of how this code would change to extract just the changed values for the page the user was on?

foreach (GridEditableItem editedItem in RadGrid1.EditItems) {

    Hashtable newValues = new Hashtable();  

    //The GridTableView will fill the values from all editable columns in the hash   

    e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
}


0
Tsvetoslav
Telerik team
answered on 09 Jul 2010, 09:44 AM
Hi jon,

The correct code is as follows:

foreach (GridDataItem editedItem in RadGrid1.EditItems) { 
  
  
    Hashtable newValues = new Hashtable();   
  
    //The GridTableView will fill the values from all editable columns in the hash    
  
    e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem.EditFormItem);
}



Regards,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jon
Top achievements
Rank 1
answered on 14 Jul 2010, 09:23 PM
I tried using these different EventArgs in the PageIndexChanged function like this:
protected void RadGrid1_PageIndexChanged(object source, GridPageChangedEventArgs e) {}
protected void RadGrid1_PageIndexChanged(object source, GridCommandEventArgs e) {
}

And I verified that the RadGrid1_PageIndexChanged function is executed, but for some reason "editedItem.EditFormItem" is always null:
if (null != editedItem.EditFormItem) {           ePageChanged.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem.EditFormItem);

So I'm unable to save any of the rows of data that the users might have added if they click on one of the paging links.  Please advise.  Should I send a sample project?
0
jon
Top achievements
Rank 1
answered on 14 Jul 2010, 11:16 PM
Ah, what might be throwing things off is that I am setting all columns in the table to be Editable on PreRender.  I'm doing this because the customers want to enter data in bulk, but when I added paging I ran into the trouble described above.  Here's my PreRender code:

protected void RadGrid1_PreRender(object sender, System.EventArgs e) {
       
  foreach (GridItem item in RadGrid1.MasterTableView.Items) {         
    if (item is GridEditableItem) {
          
     GridEditableItem editableItem = item as GridDataItem;
           
     editableItem.Edit = true;
         
    }
       
  }
       
  RadGrid1.Rebind();
   
}
0
Accepted
Tsvetoslav
Telerik team
answered on 16 Jul 2010, 11:37 AM
Hello jon,

Could you specify what type of EditMode are  you using? Is it InPlace? Is it also possible that you paste your whole aspx and code-behind.

Best wishes,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jon
Top achievements
Rank 1
answered on 16 Jul 2010, 03:26 PM
I found that the solution is w/ the Event Arguments.  This does not work:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) {

But this does:
protected void RadGrid1_ItemCommand(object source, EventArgs e) {
Tags
Grid
Asked by
jon
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
jon
Top achievements
Rank 1
Share this question
or