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

[Solved] Edit clomuns only in RADGrid

8 Answers 180 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
kachy
Top achievements
Rank 1
kachy asked on 13 Jun 2008, 04:44 PM
Is there a way, we can change only one column of a grid in edit mode. By using ClientAPI, onColumnClick, we can get the index of the column being clicked, is there a way using that Index, I can make that column editable?

Thanks.

8 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 16 Jun 2008, 02:27 PM
Hi kachy100,

I think that the sample code from the following article in our online documentation can put you on the right path in your implementation for single cell editing:

http://www.telerik.com/help/aspnet-ajax/grdreadonlymodeforindividualcells.html

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
kachy
Top achievements
Rank 1
answered on 19 Jun 2008, 08:32 PM
The requirement was to click on column header and make that column editable for all the rows. I used oncolumnclick client side event and passed the index of the column to a hiddenfield and used AJAX to refresh the grid. OnItemCreated event of the grid, I am checking the value of hiddenfield and making all other columns readonly after setting multirowedit option to true.
This works fine.
Now, I have to do the same thing for a particular cell, once the cell is clicked, that should become editable. Is there a way I can get the rowindex as well as columnindex of the cell from any client side event. Or if you could suggest something on how to make a cell editable on click.

Thanks
0
Iana Tsolova
Telerik team
answered on 23 Jun 2008, 10:49 AM
Hi kachy100,

Please review the following online resources in order to achieve your goal:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/DataEditing/EditOnDblClick/DefaultCS.aspx
http://www.telerik.com/help/aspnet-ajax/grid_onrowclick.html
http://www.telerik.com/help/aspnet-ajax/grid_edititem.html
http://www.telerik.com/help/aspnet-ajax/grdgettingfamiliarwithclientapi.html

Let us know if you need further help.

Kind regards,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
kachy
Top achievements
Rank 1
answered on 23 Jun 2008, 08:29 PM
I checked all the links but could not find answer to my question. The requirement is if user clicks on one particular cell of a grid, only that grid should become editable.

0
Iana Tsolova
Telerik team
answered on 24 Jun 2008, 10:06 AM
Hello kachy100,

Have you tried hooking up the OnRowClick client-side event of RadGrid and there put the clicked row into edit mode:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
<script type="text/javascript">  
function RowClick(sender, eventArgs)  
{  
    var tableView = eventArgs.get_tableView();  
    var rowIndex = eventArgs.get_itemIndexHierarchical();  
      
    tableView.editItem(rowIndex);  
}  
 
</script> 
</telerik:RadCodeBlock> 
<telerik:RadGrid ID="RadGrid1" runat="server">  
    <ClientSettings> 
        <ClientEvents OnRowClick="RowClick" />                 
    </ClientSettings> 
</telerik:RadGrid> 

Give it a try and let us know if this helps.

All the best,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Shinu
Top achievements
Rank 2
answered on 24 Jun 2008, 10:11 AM
Hi kachy100,

Set the ReadOnly mode for all the other columns except the required field and try the following code snippet to set the cell in edit mode on clicking the row.

ASPX:
 <input id="Hidden1" type="hidden" runat="server"  name="Hidden1"  /> 

CS:
protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "RowClick") 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
 
            item["columnUniqueName"].Attributes.Add("OnClick", "return Edit();"); 
            if (Hidden1.Value == "1") 
            { 
                item.Edit = true
            } 
            Hidden1.Value = ""
        } 
 
 
       
    } 


JS:
 <script type="text/javascript" language="javascript" > 
         function Edit()    
           {   
           
           var Hidden1document.getElementById("Hidden2");   
           Hidden1.value=1;  
            
          }   
        </script> 


Thanks
Shinu.
0
kachy
Top achievements
Rank 1
answered on 27 Jun 2008, 05:39 PM
Any of the above mentioned solutions did not work.
I am now trying to attach one javascript function on onClick event of the cell using 
http://www.telerik.com/help/aspnet/grid/grdselectingcells.html

but I get Javascript error in VS 2008- 
Microsoft JScript runtime error: 'Control.cells.length' is null or not an object

Am I missing something?

Thanks.
0
Konstantin Petkov
Telerik team
answered on 30 Jun 2008, 04:49 AM
Hi kachy100,

The RadGrid for ASP.NET AJAX client-side follows the AJAX naming convention. You can find the same code for the Grid AJAX control here.

I hope this helps!

Regards,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
kachy
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
kachy
Top achievements
Rank 1
Iana Tsolova
Telerik team
Shinu
Top achievements
Rank 2
Konstantin Petkov
Telerik team
Share this question
or