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

Saving multiple items

5 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Konstantin
Top achievements
Rank 1
Konstantin asked on 27 Jul 2008, 08:02 PM
Could you please advise how to save multiple items with the Grid?

I have created a grid with 2 read-only columns and 2 writeable check box columns, enabled MultiRowEdit, put the whole grid into the Edit mode and wanted to set check boxes and save the whole grid when I click Save.

However, I am having couple of problems: 
1. Changing pages or sorting removes all changes (probably it rebinds the grid)
2. Without rebind, I can't find how to get a primary key for the row (I added an invisible column to the grid)
3. Without rebind, I can't put Grid into Edit Mode.

Also, I have a couple of side questions (not too critical):
4. If I enable grouping by column, I can't put a grid into edit mode at all (found couple of ways on the site, none of them worked, throwing exception). Or is there a way?
5. Filtering with auto suggestions - is there a way to set it up in easy way, like asking grid to traverse all rows for specific columns, find all values and then showing them in drop downs on under selected columns?

Thank you

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Jul 2008, 06:24 AM
Hi Konstantin,

1. Go through the following help articles and see whether it helps.
      Saving grid settings on a per user basis
      Persisting CheckBox control state in GridTemplateColumn on rebind
     Persisting the selected rows on sorting/paging/filtering/grouping

2. Try setting the DataField of the invisible column as the DataKeyName and try accessing it in the ItemDataBound event as shown below.

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string strKey = item.GetDataKeyValue("ProductName").ToString(); 
        } 
    } 


Thanks
Shinu
0
Brian
Top achievements
Rank 1
answered on 04 Aug 2008, 08:58 PM
At a higher level, when a grid is in FULL edit mode and you are handling the UpdateCommand event, how does one go about saving ALL the changes?

I searched and searched but all the examples I have seen for "Mulitple Row" edits forces the user to hit the "update" button for each row.

I would like to avoid this and do it all at once in the end.

Thanks,
-Brian
0
Konstantin Petkov
Telerik team
answered on 05 Aug 2008, 05:14 AM
Hi Brian,

You can easily achieve that through the built-in commands triggered by buttons in CommandItemTemplate for example. See the following demos:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/WebGrid/DefaultCS.aspx
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/CommandItem/DefaultCS.aspx

Kind regards,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Brian
Top achievements
Rank 1
answered on 05 Aug 2008, 11:28 PM
Hi Konstanin,

Thanks for the links.  I have another question related to saving all records.  If all the records in the grid are in edit mode, how does one go about determining which records have been edited and which hasn't?  I do not want to iterate through and compare all fields for all rows.

Thanks,
0
Sebastian
Telerik team
answered on 06 Aug 2008, 07:25 AM
Hi Brian,

You may consider using edit tracking (in order to determine which items in the grid has been edited by the end user) similar to this one:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/DataEditing/EditOnDblClick/DefaultCS.aspx

Review the html/javascript implementation from the demo for further details.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Konstantin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Brian
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Sebastian
Telerik team
Share this question
or