We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GGC row order change

Thread ID:

Created:

Updated:

Platform:

Replies:

73068 Apr 18,2008 05:03 AM May 12,2008 09:54 AM Windows Forms 8
loading
Tags: Grouping
Sathishkumar Kaliavaradhan
Asked On April 18, 2008 05:03 AM

Hi All,

I want to interchange row order in GGC dynamically at runtime using move up and down button, like move first record into second position and second record into first position.

My case i am interchanging record position in datasource but it's reflecting in UI.

Please provide me an example as soon as possible.

Thanks by advance.

Regards
K.Sathishkumar


Sathishkumar Kaliavaradhan
Replied On April 22, 2008 12:39 AM

Hi All,

It's very very urgent for me, can you anyone help me?

Thanks in advance.

Regards
K.Sathishkumar


Sathishkumar Kaliavaradhan
Replied On April 25, 2008 12:30 AM

Hi All,

As i said it is very very urgent for me.Can anyone of you help me?

Thanks and Regards
K.Sathishkumar




Administrator [Syncfusion]
Replied On April 28, 2008 01:35 AM

Hi Sathishkumar,

Sorry for the delay in replying. You can use MoveRange method to interchange the rows in a GridControl. Please refer the below code snippet that shows the how we can interchange the rows.


private void button1_Click(object sender, EventArgs e)
{
this.gridControl1.Rows.MoveRange(2,3);
}


Please refer the sample in the below link that illustrates the above.

http://websamples.syncfusion.com/samples/Grid.Windows/I73068/main.htm

Please let me know if you have any questions.

Regards,
Asem.



Sathishkumar Kaliavaradhan
Replied On April 29, 2008 12:51 AM

Hi Asem,

First of all Thanks for your reply...

you gave me solutions for gridcontrol but i want for GridGroupingControl.

Can you please reply me...ASAP?

Thanks and Regards
K.Sathishkumar


sk
Replied On May 5, 2008 02:22 AM

Hi All,

I also facing same problem, can anyone of you reply me as soon as possible?

Regards
SK


SubhaSheela R [Syncfusion]
Replied On May 5, 2008 07:17 AM

Hi Sathish,

Sorry for the long delay caused.

In a GridGrouping Control, the grid just displays the rows as they are presented to it by the underlying datasource. So, if you want to move the position of the rows currently, you have to do so by moving them in the underlying datasource.
One way of doing it is to add an additional column to the datatable that holds a sortKey that reflects where you want the rows to be. You don't display this column ( you can just hide it in the grid as the sample does). When you initially set the DataSource to the grid, you sort the datatable on this column using its defaultview.sort property. Then when you want to move rows, all you have to do is to move the sortKey values and the rows will rearrange themselves (as they must maintain the sort order).


void Swap(int row1, int row2)
{
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.gridGroupingControl1.DataSource, this.gridGroupingControl1.DataMember];

if (row1 < cm.Count && row2 < cm.Count && row1 > -1 && row2 > -1)
{
DataRowView drv1 = (DataRowView)cm.List[row1];
int val1 = (int)drv1.Row["sortKey"];
DataRowView drv2 = (DataRowView)cm.List[row2];
int val2 = (int)drv2.Row["sortKey"];
drv1.Row["sortKey"] = val2;
drv2.Row["sortKey"] = val1;
}
}


Here is the sample:

http://websamples.syncfusion.com/samples/Grid.Windows/Grid_WF_GGCSwapRowsF73068/main.htm">

Please have a look into the above sample and let me know if it helps.

Regards,
Subhasheela R




Administrator [Syncfusion]
Replied On May 6, 2008 02:19 AM

Hi Subhasheela,

Thanks for your reply...

Actually i am using List as DataSource, could you please tell me how do i do?

Thanks and Regards
SK




SubhaSheela R [Syncfusion]
Replied On May 12, 2008 09:54 AM

Hi Sathish,
We regret for the long delay in getting back to you.
You can achieve the desired behavior getting the record in temporary record and swap it. Below is the code snippet:

public void SwapRecords( int recordIndex1, int recordIndex2)
{
for (int j = 0; j < this.gridGroupingControl1.TableDescriptor.Columns.Count; j++)
{
Record record1 = this.gridGroupingControl1.Table.Records[recordIndex1];
Record record2 = this.gridGroupingControl1.Table.Records[recordIndex2];
string colName = this.gridGroupingControl1.TableDescriptor.Columns[j].Name;
object tmp = record1.GetValue(colName);
record1.SetValue(colName, record2.GetValue(colName));
record2.SetValue(colName, tmp);
}
}

Here is the sample:
http://websamples.syncfusion.com/samples/Grid.Windows/Grid_WF_GGCSwappingRecordsF73068FU1/main.htm

Please have a look into the above sample and let me know if it helps.
Regards,
Subhasheela R




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;