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

Save only Modied Rows of Rad Grid

4 Answers 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kalyan gupta
Top achievements
Rank 1
kalyan gupta asked on 09 Aug 2010, 03:58 PM
Hi @
I am using Silverlight 4 Rad Grid in one of my VS 2010 application.
I have an Edittable Grid in my page. I need to save only modified rows on click of Update button.
Please let me know how will we know the rows which are modified.
I do not want to hit the database for all the rows.
I am binding a List<T> to RadGrid
Thanks in advance
Kalyan

4 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 09 Aug 2010, 04:02 PM
Hello kalyan gupta,

 RIA Domain Data Services only send the modified items to the database by default. If you're using a custom WCF service, though, you need to implement your own logic that gets only the modified items from your items source.

Best wishes,
Yavor Georgiev
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
kalyan gupta
Top achievements
Rank 1
answered on 09 Aug 2010, 04:20 PM
Hi Thanks for the quick reply.

Following is the code I am using..

Please let me know how will I set the IsRowModified Property of particular row being edited??

******************************************.Xaml.cs***********************************************************
public class GridItemsCollections
    {
        #region Variables
        string pstrFirstName;
        string pstrMiddleName;
        string pstrLastName;
        string pstrCountry;
 string pstrIsRowModified;      
        #endregion
        /// <summary>
        ///
        /// </summary>
        public GridItemsCollections()
        {
            pstrFirstName = string.Empty;
            pstrMiddleName = string.Empty;
            pstrLastName = string.Empty;
            pstrCountry = string.Empty;
     pstrIsRowModified = string.Empty;           
        }
        #region Properties       
        public string FirstName
        {
            get { return pstrFirstName; }
            set { pstrFirstName = value; }
        }
        public string MiddleName
        {
            get { return pstrMiddleName; }
            set { pstrMiddleName = value; }
        }
        public string LastName
        {
            get { return pstrLastName; }
            set { pstrLastName = value; }
        }
        public string Country
        {
            get { return pstrCountry; }
            set { pstrCountry = value; }
        }
 public string IsRowModified
        {
            get { return pstrIsRowModified; }
            set { pstrIsRowModified = value; }
        }
        #endregion
    }

 public uctrlAddUpdateGrid(string pstrSelectedProgram)
        {
     InitializeComponent();           
           
            GridItemsCollections lobjCmbItemColl;
            llstCmbItemColl = new List<GridItemsCollections>();

  for (int i = 0; i < 100000; i++)
                {
                    lobjCmbItemColl = new ComboItemsCollections();                   
                    lobjCmbItemColl.FirstName = "First Name_" + (i + 1).ToString();
                    lobjCmbItemColl.MiddleName = "Middle Name_" + (i + 1).ToString();
                    lobjCmbItemColl.LastName = "Last Name_" + (i + 1).ToString();
                    lobjCmbItemColl.Country = "Country_" + (i + 1).ToString();
      llstCmbItemColl.Add(lobjCmbItemColl);
  }

  radGridView1.ItemsSource = llstCmbItemColl;  

 }

 private void btnSaveInsertEdit_Click(object sender, RoutedEventArgs e)
        {
  //Here I want to form a list which contains the modified rows of Grid.
  if(IsRowModified == "Y")
  {
   
  }
 }

 private void radGridView1_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
  
        }

        private void radGridView1_BeginningEdit_1(object sender, GridViewBeginningEditRoutedEventArgs e)
        {
  //I got this event in RadGrid.. But how will I know which Row is being edited.. say i clicked on 3rd Row.. I want to set IsRowModified property of 3rd     //Object in RadGrid's Itemsource to "Y"
        }

 

******************************************.Xaml***********************************************************

<Button FontFamily="Arial" Content="Save insert/edit" Grid.Row="1" Height="23" HorizontalAlignment="Left" Name="btnSaveInsertEdit" VerticalAlignment="Center" Click="btnSaveInsertEdit_Click" Width="100" Margin="10,0,0,0"/>

<telerik:RadGridView FrozenColumnCount="3" FontFamily="Arial"  AutoGenerateColumns="False" HorizontalAlignment="Left" Name="radGridView1" VerticalAlignment="Top"
                             Height="380" Width="500" CanUserDeleteRows="True" Margin="10,10,0,0" RowEditEnded="radGridView1_RowEditEnded" BeginningEdit="radGridView1_BeginningEdit_1" >
                <telerik:RadGridView.Columns>
                    <telerik:GridViewColumn>
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <telerik:RadButton Content="-" CommandParameter="{Binding}"/>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewCheckBoxColumn Header="Check box Column"></telerik:GridViewCheckBoxColumn>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="First Name"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding MiddleName}" Header="Middle Name"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="Last Name"></telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}" Header="Country"></telerik:GridViewDataColumn>                  
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>


Hope this is clear. Please let me know if this is not clear.

Thanks in advance.
Kalyan gupta
0
Accepted
Yavor Georgiev
Telerik team
answered on 09 Aug 2010, 04:35 PM
Hi kalyan gupta,

 You can handle the RowEditEnded event of RadGridView and set the IsRowModified property on your model from there.

Regards,
Yavor Georgiev
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
kalyan gupta
Top achievements
Rank 1
answered on 10 Aug 2010, 06:00 AM

The following code helped me in Setting the IsRowModified property of collection.

 

 

((GridItemsCollections)(((sender as RadGridView).CurrentCell as GridViewCell).ParentRow.DataContext)).IsRowModified = "Y";

Thanks
Kalyan Gupta B

Tags
GridView
Asked by
kalyan gupta
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
kalyan gupta
Top achievements
Rank 1
Share this question
or