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

[Solved] CommandItemSettings question

3 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Babu Mannaravalappil
Top achievements
Rank 1
Babu Mannaravalappil asked on 03 Nov 2009, 01:15 PM
Hi,

I have a few questions:
Environment: RadControls for ASP.net 2009 Q2.

1. On the commanditems strip, I would like to show some custom commands, like an edit button when clicked, would put certain cells in certain rows in edit mode based on some business rules.  I would also like to put an "Update" button on this strip which will fire a custom method on the server to update the edited rows in the grid. These buttons will also be hidden under certain conditions. How would I do that?

2. I don't see any property either at desgin time or in code to add the button "Export to Excel" to this commanditem strip.  The online examples on your site have some "ShowExportToExcelButton" property set.  But I don't see it at either design time or at runtime.  How do I do this?

3. I would also like to set some of the cells in certain rows, only in certain columns, non-editable and some others editable (when Edit button clicked).  What is the appropriate event handler to put this code in?

Thanks

Babu.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Nov 2009, 06:15 AM
Hello Babu,

1) You can use the CommandItemTemplate to add custom buttons into it and set CommandNames for the buttons which would trigger the ItemCommand event of the grid. Check out this online demo which illustrates on the same functionality you require:
Command Item
Also the following document explains on how to update all the edited rows together on clicking a button:
Performing batch updates

2) You can add a custom export button in the CommandItemTemplate and set its CommandName to Export to Excel which will automatically trigger the export functionality.

3) You can set the ReadOnly property for the non-editable columns to true as shown below:
<telerik:GridBoundColumn UniqueName="BoundColumn" ReadOnly="true" DataField="ProductName" HeaderText="NonEditableColumn"
</telerik:GridBoundColumn> 

Thanks
Princy.
0
Babu Mannaravalappil
Top achievements
Rank 1
answered on 04 Nov 2009, 12:26 PM
Thank you Princy for the response.

On my third question, about making cells readonly, I need to do this at runtime.  I need to make cells non editable based on some business rules.  So, what would be the appropriate Event handler where I can get access to cell, column and row objects in one place so that I can modify the readonly property.

Thanks.

Babu.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 04 Nov 2009, 12:55 PM
Hi Babu,

You can set the ReadOnly property for the non-editable columns from code behind by using its UniqueName property:
c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
        { 
            if (col.UniqueName == "BoundColumn1UniqueName" || col.UniqueName == "BoundColumn2UniqueName"
            { 
                (col as GridBoundColumn).ReadOnly = true
            } 
        } 
    } 

Thanks
Shinu.
Tags
Grid
Asked by
Babu Mannaravalappil
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Babu Mannaravalappil
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or