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

Column Order

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clint Leonard
Top achievements
Rank 1
Clint Leonard asked on 20 Aug 2010, 02:36 PM

Can someone tell my why my GridButtonColumn Below shows up as the 1st column for this grid, instead of as the last column as specified?

    <telerik:RadGrid ID="rgACWF1" runat="server" AllowCustomPaging="True" OnItemDataBound="rgACWF1_ItemDataBound"
            AllowPaging="True" AutoGenerateColumns="False" GridLines="None" OnItemCreated="rgACWF1_ItemCreated" OnItemCommand="rgACWF1_ItemCommand" AllowAutomaticInserts="false">
            <PagerStyle BackColor="White" Mode="Advanced" ShowPagerText="false" Position="Bottom" />
            <MasterTableView AllowCustomSorting="True" datakeynames="ID" EditMode="InPlace" CommandItemDisplay="Bottom" InsertItemDisplay="Bottom" TableLayout="Auto">
              
                <Columns>                    
                    <telerik:GridEditCommandColumn UniqueName="ACWF1EditCommandColumn" InsertText="Save" UpdateText="Save" />
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Rating" />
                    <telerik:GridNumericColumn DataField="Value" HeaderText="Value" />
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="ACWF1DeleteColumn" />                    
                </Columns>
  
                <CommandItemSettings AddNewRecordText="Add New" RefreshText="Refresh" />
                     
<%--                <CommandItemTemplate>
                      <asp:Button runat="server" ID="btnAddConfidentialityScore" Text="Add" CommandName="AddConfidentialityScore" />
                </CommandItemTemplate>   --%>
                                 
            </MasterTableView>
    </telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 20 Aug 2010, 03:01 PM
Hello Clint,

I do not observe such a behavior locally. Do you reorder columns on the server?

http://www.telerik.com/help/aspnet-ajax/grdreorderingcolumns.html

Here is my test page:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<script runat="server">
 
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable dt = new DataTable();
        DataRow dr;
        int rowsNum = 30;
        string[][] colsInfo = {
        new string[] { "ID", "number" },
        new string[] { "Name", "string" },
        new string[] { "Value", "number" }
    };
 
        for (int i = 0; i < colsInfo.Length; i++)
        {
            switch (colsInfo[i][1])
            {
                case "string":
                    dt.Columns.Add(new DataColumn(colsInfo[i][0], typeof(String)));
                    break;
                case "number":
                    dt.Columns.Add(new DataColumn(colsInfo[i][0], typeof(Int32)));
                    break;
                case "date":
                    dt.Columns.Add(new DataColumn(colsInfo[i][0], typeof(DateTime)));
                    break;
                case "bool":
                    dt.Columns.Add(new DataColumn(colsInfo[i][0], typeof(Boolean)));
                    break;
                default:
                    break;
            }
        }
 
        for (int j = 1; j <= rowsNum; j++)
        {
            dr = dt.NewRow();
 
            for (int k = 0; k < colsInfo.Length; k++)
            {
                switch (colsInfo[k][1])
                {
                    case "string":
                        dr[colsInfo[k][0]] = String.Format("{0} Row{1}", colsInfo[k][0], j);
                        break;
                    case "number":
                        dr[colsInfo[k][0]] = j;
                        break;
                    case "date":
                        dr[colsInfo[k][0]] = DateTime.Now;
                        break;
                    case "bool":
                        dr[colsInfo[k][0]] = j % 2 == 1 ? true : false;
                        break;
                    default:
                        break;
                }
            }
            dt.Rows.Add(dr);
        }
 
        (sender as RadGrid).DataSource = dt;
    }
     
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
    <telerik:RadGrid ID="rgACWF1" runat="server" AllowCustomPaging="True" OnNeedDataSource="RadGrid_NeedDataSource"
            AllowPaging="True" AutoGenerateColumns="False" GridLines="None" AllowAutomaticInserts="false">
            <PagerStyle BackColor="White" Mode="Advanced" ShowPagerText="false" Position="Bottom" />
            <MasterTableView AllowCustomSorting="True" datakeynames="ID" EditMode="InPlace" CommandItemDisplay="Bottom" InsertItemDisplay="Bottom" TableLayout="Auto">
               
                <Columns>                   
                    <telerik:GridEditCommandColumn UniqueName="ACWF1EditCommandColumn" InsertText="Save" UpdateText="Save" />
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Rating" />
                    <telerik:GridNumericColumn DataField="Value" HeaderText="Value" />
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="ACWF1DeleteColumn" />                   
                </Columns>
   
                <CommandItemSettings AddNewRecordText="Add New" RefreshText="Refresh" />
                      
<%--                <CommandItemTemplate>
                      <asp:Button runat="server" ID="btnAddConfidentialityScore" Text="Add" CommandName="AddConfidentialityScore" />
                </CommandItemTemplate>   --%>
                                  
            </MasterTableView>
    </telerik:RadGrid>
 
</form>
</body>
</html>


Greetings,
Dimo
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
Clint Leonard
Top achievements
Rank 1
answered on 20 Aug 2010, 03:03 PM
They must be getting reordered within some code on the server side.

I'll look into that.

Thanks for the quick response.
Tags
Grid
Asked by
Clint Leonard
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Clint Leonard
Top achievements
Rank 1
Share this question
or