1

I am trying to hide the Telerik RadGrid Edit column until the user clicks on the row the user wants to edit. Upon the click event I need the Edit hyperlink column set to Visible="true". I was hoping to set the column as Visible="false" by default, and then add a click event in my .cs page to alter the visibility property, but I cannot figure out how to target the edit column... Here is my code for the .aspx page.

<telerik:RadGrid ID="RG_POI" runat="server" OnPreRender="RG_POI_PreRender" OnItemDataBound="RG_POI_ItemDataBound" >
    <MasterTableView EditMode="InPlace" >
        <Columns>
            <telerik:GridEditCommandColumn Visible="false"/>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn1 column" UniqueName="EditCommandColumn1">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
DanM7
  • 2,101
  • 3
  • 25
  • 45
Christoa
  • 69
  • 7
  • How is classic ASP relevant here? – DanM7 Oct 16 '14 at 14:47
  • Bare in mind; I am new to the programming field. Are you saying that ASP is not present in this code? What language is it I am utilizing? – Christoa Oct 16 '14 at 16:02
  • They're much different. Welcome to programming! Check out this section for more info: http://en.wikipedia.org/wiki/ASP.NET#ASP.NET_compared_with_classic_ASP – DanM7 Oct 16 '14 at 16:43
  • When you say "until the user clicks on the row the user wants to edit" do you mean the user clicking the row is the signal they want to edit? Or do they need to click something else like an "Edit" button? – DanM7 Oct 16 '14 at 16:51
  • I'm not sure how familiar you are with Telerik's RadGrid. Maybe I failed to specify something... In Telerik's RadGrid; you can enable an editing column, which is basically just a column within which each row is occupied by an "Edit" hyperlink. What I want to happen seems rather simple if I could just figure out how to target that specific column... I want the Edit column to be hidden by default, but when the user clicks within one of the rows of the RadGrid, I want the Edit column to become visible. – Christoa Oct 16 '14 at 18:03
  • Got it -- check my answer below. Big fan of Telerik. Check out my profile! – DanM7 Oct 16 '14 at 19:52

1 Answers1

0

You can do this via C# or JavaScript. If you use C#, you can remove the OnRowSelected="gridSelected" from the grid definition below; if you use JavaScript then remove the OnSelectedIndexChanged="rgTest_SelectedIndexChanged":

ASPX:

<telerik:RadGrid ID="RG_POI" ... OnSelectedIndexChanged="rgTest_SelectedIndexChanged">
    <ClientSettings ... >
        <ClientEvents OnGridCreated="gridCreated" OnRowSelected="gridSelected" />
    </ClientSettings>
    <MasterTableView ... >
        <Columns>
            <telerik:GridEditCommandColumn UniqueName="Edit" />
            ...

Option 1) C#:

protected void rgTest_SelectedIndexChanged(object sender, EventArgs e)
{
    RG_POI.Columns[1].Visible = true;
}

Option 2) JavaScript:

function gridCreated(menu, args) {
    var radGrid = $find('RG_POI');
    var table = radGrid.get_masterTableView();
    table.shideColumn(1);
}

function gridSelected(menu, args) {
    var radGrid = $find('RG_POI');
    var table = radGrid.get_masterTableView();
    table.showColumn(1);
}
DanM7
  • 2,101
  • 3
  • 25
  • 45
  • This did not work for me. I do not get any errors, but at the same time the IndexChanged event does not make the Edit Column visible. :/ I may need to use a button to do this? – Christoa Oct 17 '14 at 14:03
  • No, you shouldn't need a different button. Either of these solutions should work. If you go the C# route, can you debug the event handling and make sure the event is fired? What are the visibility properties on all of the columns? Is "1" not the correct index on your grid? – DanM7 Oct 17 '14 at 14:28