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

Editable column

3 Answers 159 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amruta Deshpande
Top achievements
Rank 1
Amruta Deshpande asked on 06 Dec 2011, 02:12 PM
Hello,
        I wanted to know whether in the grid are you able to make the entire column editable? My requirement is that on page load I need to show few columns of the grid as editable. The editable columns contain either a combobox, a date type textbox or the simple textbox.
Rest of the columns should not be editable.

Also I have another question, how to get the cell index when I click on a particular cell of the grid. Or if I enter some data into the cell, is it possible to get the cell id for that particular cell from client side?

Thank You
Amruta Deshpande

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Dec 2011, 08:42 AM
Hello Amrutha,

Try the following code for putting the column in edit mode.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
   foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
     {
       item.Edit = true;
    }
     RadGrid1.Rebind();
}
Try the following javascript for accessing the cell value.
JS:
function OnRowSelecting(sender, args)
  {
     var grid = sender;
     var masterTable = grid.get_masterTableView();
     var row = args.get_gridDataItem();
     var cell = masterTable.getCellByColumnUniqueName(row, "ColumnUniqueName");
     alert(cell.innerHTML);
  }

-Shinu.
0
Amruta Deshpande
Top achievements
Rank 1
answered on 07 Dec 2011, 09:31 AM
Hello,
        I tried embedding the code you provided into my page, but that is again on row selecting right? I want to ask whether is it possible to get the cell index or cell id after I edit the that particular cell?
I am attaching a screen shot of my grid explaining my requirements.

Thank You
Amruta Deshpande
0
Iana Tsolova
Telerik team
answered on 09 Dec 2011, 05:10 PM
Hello Amruta,

One column can have a single type of editor, e.g. textbox, or combobox, or date input. But it is not possible to display different controls based on custom conditions with the built-in columns. You can use however a template column and then take care for displaying the proper editor.

To get the cell id with javascript, you can get the parentNode.id from some event of the editor control, say onblur, onkeypress or onkeydown for instance.

Kind regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Amruta Deshpande
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Amruta Deshpande
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or