0

I have a grid which consists of a queryable datasource and template column.

       <telerik:RadGrid ID="rulesGrid" runat="server" AutoGenerateColumns="true">
      <MasterTableView>
      <Columns>
      <telerik:GridTemplateColumn HeaderText="Status" UniqueName="statusResult">
       </telerik:GridTemplateColumn>
       </Columns>
      </MasterTableView>

     </telerik:RadGrid>

And in the page_load

     var ruleset = (from s in (this.Page as BasePage).DbContext.ProductEventChecks
                       where s.Sequence!=0
                       orderby s.Sequence
                       select new
                       {
                           Description = s.Description
                       });

        rulesGrid.DataSource = ruleset;
        rulesGrid.DataBind();

So, the problem is that status field(template column) comes before the Description field. But I wanted Description to be displayed first. Can you please help me out in finishing this?

user1344343
  • 31
  • 1
  • 4

1 Answers1

2

Please check below code snippet.

.aspx

 <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
    AllowPaging="True" OnPreRender="RadGrid1_PreRender" 
    AutoGenerateColumns="true" oncolumncreated="RadGrid1_ColumnCreated">
    <PagerStyle AlwaysVisible="true" />
    <MasterTableView>

    </MasterTableView>
</telerik:RadGrid>

.aspx.cs

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    dynamic data = new[] {
            new { ID = 1, Name ="Name1"}
        };

    RadGrid1.DataSource = data;
}
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
    if (e.Column.UniqueName == "ID")
    {
        e.Column.OrderIndex = 1;
    }
    else if (e.Column.UniqueName == "Name")
    {
        e.Column.OrderIndex = 0;
    }

}
Jayesh Goyani
  • 11,008
  • 11
  • 30
  • 50