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

Selecting rows in an item template

4 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reid
Top achievements
Rank 2
Reid asked on 16 Feb 2009, 02:10 PM

Using an ajaxified RadGrid (latest and greatest version) I have implemented a custom Command Template to facilitate add, edit, insert, update, and cancel actions based on demos here.

            
This works fine but does not work for editing or deleting if you are using a custom <ItemTemplate>.  I say this because as such it relies on a "selected" row or item in the grid. I have the code to select the row on the client side but cannot figure out how to display or enact the selected row when using the custom <ItemTemplate>.

So the questions are:

  1. How does the selected row strategy work with custom ItemTemplates?
  2. As an alternative, are there any examples of showing two small columns side by side with icons only for the AutoGenerated "Edit" and "Delete" columns instead of the default?

Thank you,

P.S.  Try posting a message with a title of "Custom <CommandTemplate> when using a custom <ItemTemplate>".  The server will not accept it.

4 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 18 Feb 2009, 10:19 AM
Hello Reid,

RadGrid row selection works same way no matter what type of columns you have in your grid columns collection.

Regarding the auto generated edit and delete columns, try handling the grid PreRender event as shown below:

protected void RadGrid1_PreRender(object sender, EventArgs e)  
{  
    foreach (GridColumn column in RadGrid1.MasterTableView.Columns)  
    {  
        if (column.ColumnType == "GridButtonColumn")  
        {  
            (column as GridButtonColumn).ButtonType = GridButtonColumnType.ImageButton;  
        }  
        if (column.ColumnType == "GridEditCommandColumn")  
        {  
            (column as GridEditCommandColumn).ButtonType = GridButtonColumnType.ImageButton;  
        }  
    }  

Let me know if this helps.

All the best,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Reid
Top achievements
Rank 2
answered on 18 Feb 2009, 02:58 PM
Hello Lana,

Thank you for responding.

I deployed the code you display below and the grid still shows the command columns as "Edit", "Delete" Links and not icons when the page loads.  After I click on one of the linkbutton commands and the MasterEditTemplate shows, the icons then show.  Do you know why they are not showing initially?
0
Accepted
Iana Tsolova
Telerik team
answered on 19 Feb 2009, 10:12 AM
Hello Reid,

Can you try moving the sample code in RadGrid ColumnCreated event and see if it makes any difference?

Let me know how it goes.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Reid
Top achievements
Rank 2
answered on 19 Feb 2009, 05:44 PM
Thank you Lana, that solved it. :)
Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Iana Tsolova
Telerik team
Reid
Top achievements
Rank 2
Share this question
or