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

[Solved] RadGrid column order index

4 Answers 527 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 03 Feb 2014, 02:21 PM
HI,
     Currently i am using a radgrid control in our application. I have enabled client side column reorder "true". after that i am saving the preference in database , so that when the user revisit the page it will maintain the column order from database.
The issue i am facing is, it is storing same order index for two columns, can any one help me how i will get unique order index for each column.

my code:
 foreach (GridColumn col in RadGridSearch.MasterTableView.Columns)
                {
                    if (col.UniqueName == "Status" || col.UniqueName == "Deletecolumn" ||
                        col.UniqueName == "GridEditColumn" || col.UniqueName == "DetailView" ||
                        col.UniqueName == "ContactDetails" || col.UniqueName == "ActiveFlag1")
                        continue;
                    else
                    {
                        Int64 UserProfileFieldID = 0, UserProfileID = 0;
                        int SortType = 0, SortSequence = 0;

                        DataRow dr;
                        dr = configData.Tables["UserProfileFields"].NewRow();
                        dr[0] = Convert.ToInt32(col.UniqueName.Split('-')[1]); // Field Number

                        GetFieldValues(GetColumnName(col), Convert.ToInt32(col.UniqueName.Split('-')[1]),
                                ref SortType, ref SortSequence, ref UserProfileFieldID, ref UserProfileID);

                        dr[1] = SortType; // Sorting Type
                        dr[2] = SortSequence; // Sorting Sequence
                        dr[3] = col.OrderIndex; // Column Index
                        dr[4] = col.HeaderStyle.Width.Value;  // Column Size

                        dr[5] = col.EvaluateFilterExpression().ToString(); // Filter exp
                        if (!string.IsNullOrEmpty(col.EvaluateFilterExpression()))
                        {
                            filterSeq = filterSeq + 1;
                            dr[6] = filterSeq;
                        }
                        else
                            dr[6] = 0;

                        dr[7] = col.Display; // Show in UI

                        if (objSearchView.Session["UserPreference"] != null)
                        {

                            dr[8] = UserProfileFieldID; // UserProfileFieldID
                            dr[9] = UserProfileID;  // UserProfileID
                        }
                        configData.Tables["UserProfileFields"].Rows.Add(dr);
                        temp++;
                    }
                }

                AddUserProfileDetail(IdentifierType, objSearchView.Session["UserDescription"] as string, "CustomerSearch", "RadGridSearch", RadGridSearch.MasterTableView.PageSize, RadGridSearch.MasterTableView.FilterExpression, configData);
                //ScriptManager.RegisterStartupScript(objSearchView.Page, objSearchView.GetType(), "alertMessage", "alert('User Preference Saved Successfully')", true);
                //LoadCustomerColumns();
            }
}

Thanks In advance.

4 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 06 Feb 2014, 02:18 PM
Hello Rahul,

I prepared a small sample which demonstrates a possible solution for your case. Basically you save the order index of each column in a Session and then retrieve them from there. Please give the sample a try and let me know about the result.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Rahul
Top achievements
Rank 1
answered on 13 Mar 2014, 12:57 PM
Hi Thanks, But this is not what i have asked for.
We have a grid view and check box Context menu for header columns. For enabling the column and disabling the grid view columns.

Steps to recreate the issue:
1. Populate the grid with data
2. Move the 3rd column to 1st column
3. Now right click on the grid header , We will get the check box context menu. Now un check the moved 3rd column in the check box context menu.
4. Now right click on the Grid view header and check the unchecked 3rd column
5. Now actually the 3rd column should get displayed in the 1st column position, Insted it will display in the 2nd column position.
5. Now in the Item bound event, try to get the col.OrderIndex, You will get the duplicate order for the 3rd column.

Kindly respond ASAP, Since we are having more items to complete. If possible we shall get into the call in case you do  not understand the issue.


0
Rahul
Top achievements
Rank 1
answered on 17 Mar 2014, 07:59 AM
Please respond....
0
Kostadin
Telerik team
answered on 18 Mar 2014, 08:59 AM
Hello Rahul,

I was not able to replicate the issue by using the latest version of our controls (Q1 2014). I prepared a video which demonstrates that after following the provided steps the column are displayed in the correct order. Additionally I attached the test sample so you could try it at your end.

Regards,
Kostadin
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Rahul
Top achievements
Rank 1
Share this question
or