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

[Solved] Inline Edit Mode on single click

2 Answers 321 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shanthala Somashekar
Top achievements
Rank 1
Shanthala Somashekar asked on 16 Jul 2009, 01:07 PM
Is it possible to take the grid row into Inline Edit Mode on a single click. I want the previous row's update command to be fired and the edited row's Edit Command events to be fired. If the update command fails due to validation, I want to be able to retain the user in the previous row. There is an example using double-click and click which I have already looked into but I want to something similar with a single row click.

Thanks

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jul 2009, 02:16 PM
Hi Shanthala,

Try the following approach in order to update row on single click of grid row.

ASPX:
 
<telerik:RadGrid ID="RadGrid2" runat="server" DataSourceID="SqlDataSource1" GridLines="None" OnUpdateCommand="RadGrid1_UpdateCommand"
    <MasterTableView EditMode="InPlace" DataSourceID="SqlDataSource1"
    </MasterTableView> 
    <ClientSettings> 
        <ClientEvents OnRowClick="RowClick" /> 
    </ClientSettings> 
</telerik:RadGrid> 
 
<telerik:RadAjaxManager ID="RadAjaxManager2" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 

JavaScript:
 
<script type="text/javascript"
function RowClick(sender, eventArgs) 
 { 
    var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>"); 
    ajaxManager.ajaxRequest(eventArgs.get_itemIndexHierarchical());     
 } 
</script> 

C#:
 
protected void Page_Load(object sender, EventArgs e) 
    if(!IsPostBack) 
    ViewState["Value"] = ""
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
    if (RadGrid1.EditIndexes.Count == 0) 
    { 
        GridDataItem item = (GridDataItem)RadGrid1.MasterTableView.Items[e.Argument]; 
        item.Edit = true
        ViewState["Value"] = e.Argument; 
        RadGrid1.Rebind(); 
    } 
    else 
    { 
        if (ViewState["Value"] != ""
        { 
            GridDataItem item = (GridDataItem)RadGrid1.MasterTableView.Items[ViewState["Value"].ToString()]; 
            //firecommand 
            item.FireCommandEvent("Update", String.Empty); 
            GridDataItem item1 = (GridDataItem)RadGrid1.MasterTableView.Items[e.Argument]; 
            item1.Edit = true
            ViewState["Value"] = e.Argument; 
            RadGrid1.Rebind(); 
        } 
    } 
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) 
    // Update the row 

-Shinu.
0
Shanthala Somashekar
Top achievements
Rank 1
answered on 16 Jul 2009, 02:39 PM

Thank you for the quick reply. I have three questions

1) If I dont use the RadAjaxManager and use the standard ScriptManager and UpdatePanel around the grid, is there any other event I can fire from the client side similar to your AjaxRequest.
2) If the update fails after using the FireCommandEvent(update..), how can I track that and retain the user in the edited row.
3) I also need the ability to insert a new record. I have the CommandItemDisplay set to Top which displays the insert row with the different column editors but since I enter into edit mode on row click and not have a update/edit/cancel command column, I dont have an explicit insert icon on the insert row. How do I get a insert command to show up and trigger. Any ideas.

 

 

 

Thanks

Tags
Grid
Asked by
Shanthala Somashekar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Shanthala Somashekar
Top achievements
Rank 1
Share this question
or