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

Customizing Radgrid

1 Answer 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saurabh
Top achievements
Rank 1
Saurabh asked on 06 Nov 2014, 05:58 AM
Hello guys, 

I am totally new in Talerik Radgrid, so please bare with me. I have Raggrid inside one of the page. i am using Advance Binding (need data source) to bind my data. which is working perfectly fine. 

now my problem is, I want to customize the columns. Here what i want to do.

1. How can i change the Column Header 
2. How can i remove Filter box from some of my columns. 
3. How can i Hide some column to display in grid. 
4. How can i customize Sorting. in specific columns.


And also, can anyone please explain me the concept of UniqueName. Thanks. 

Here what i do to bind the data.  

.xaml page. 
<telerik:RadGrid runat="server" ID="RadGrid2" AllowPaging="True" AllowSorting="true"
        OnNeedDataSource="RadGrid2_NeedDataSource" AllowFilteringByColumn="True" Skin="Sunset">
        <ClientSettings>
            <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
            
        </ClientSettings>
    </telerik:RadGrid>

.cs page
protected void RadGrid2_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
       {
           (sender as RadGrid).DataSource = GetDataTable();
       }
 
       public DataTable GetDataTable()
       {
           string str1 = (string)(Session["UserName"]);
 
           string query = "select Acer_Status,No_Of_Vouchers,Acer_Actual_Balance ,Zero_To_Thirty_Days , Thirtyone_To_Sixty_Days ,Sixtyone_To_Ninety_Days ,Ninetyone_Days_Plus  from ACER_AR_SUMMARY1 where Practice_Short_Name ='" + str1 + "'";
 
           String ConnString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
           SqlConnection conn = new SqlConnection(ConnString);
           SqlDataAdapter adapter = new SqlDataAdapter();
           adapter.SelectCommand = new SqlCommand(query, conn);
 
           DataTable myDataTable = new DataTable();
 
           conn.Open();
           try
           {
               adapter.Fill(myDataTable);
              
           }
           finally
           {
               conn.Close();
           }
 
           return myDataTable;
       }


1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 10 Nov 2014, 01:16 PM
Hello Saurabh,

When you use auto-generated column, in order to change some of their properties you could handle the server-side OnColumnCreated event of the grid. Detailed information on this matter is available in the following help article:
The event will fire for each generated column and you could use the e.Column.UniqueName for getting reference to a specific column.

Once you have the column you could customize each one of them, but please note that for some properties you may need to cast the project to the corresponding type. You could find what type of columns are generated, depending on the underlying data type in the above help article.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Saurabh
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or