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

Maintaining doubleclick/rightclick functionality with Batch Edit

2 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 19 Aug 2014, 04:50 PM
Hello everyone,

I am trying to implement a RadGrid that supports Batch editing. The main reason I want to implement this feature (EditMode="Batch") is to be able to add new records inline in the grid. I have been able to get the new record functionality that I desire, but it has broken the functionality that I implemented for both a double click and right click. Inline editing is not a requirement for me. Is there anyway to allow for inline additions of new records, while disabling the inline edit functionality in order to allow for right click and double click functionality of already added records?

RadGrid/MasterTableView ASPX:
<telerik:RadGrid ID="RadGridActionItem" runat="server" AllowSorting="True" AllowPaging="true"
    AllowFilteringByColumn="True" OnNeedDataSource="RadGridActionItem_NeedDataSource"
    OnPageIndexChanged="RadGridActionItem_PageIndexChanged" OnItemCreated="RadGridAction_ItemCreated"
    OnDeleteCommand="RadGridActionItem_DeleteCommand" OnInsertCommand="RadGridActionItem_InsertCommand"
    AllowMultiRowEdit="True" OnItemDataBound="RadGridActionItem_ItemDataBound" Width="80%"
    HorizontalAlign="Center" PageSize="15" EnableViewState="true" Skin="Windows7">
    <GroupingSettings CaseSensitive="false" />
    <MasterTableView AutoGenerateColumns="false" ShowFooter="true" DataKeyNames="Action_Item_Id"
        ClientDataKeyNames="Action_Item_Id" CommandItemDisplay="Top" Width="100%" HorizontalAlign="Center"
        EditMode="Batch">

Right Click Functionality (C#):
protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
{
    // Right click context menu selection event.
 
    int radGridClickRowIndex;
    string actionItemId;
    bool copied = true;
 
    // Get row index and Action_Item_Id associated with row
    radGridClickRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]);
    actionItemId = RadGridActionItem.MasterTableView.DataKeyValues[radGridClickRowIndex]["Action_Item_Id"].ToString();
 
    switch (e.Item.Text)
    {
        case "Copy":
            Response.Redirect("NewActionItem.aspx?ActionId=" + actionItemId + "&IsCopied=" + copied);
            break;
    }
}

DoubleClick Functionality (JS):
<script type="text/javascript">
    function RowDblClick(sender, args) {
        var dblClick;
        dblClick = true;
        var index = args.get_itemIndexHierarchical();
        var updateActionId = args.getDataKeyValue("Action_Item_Id");
        window.location.href = "NewActionItem.aspx?DblClick=" + dblClick + "&UpdateActionId=" + updateActionId;
    }
</script>

Once again, my main goal is to be able to add new records inline within the RadGrid while maintaining already implemented rightclick and doubleclick functionality. Any help I can get would be greatly appreciated. Thanks!

-Matt

2 Answers, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 1
answered on 19 Aug 2014, 08:23 PM
I was able to find a solution my setting OpenEditingEvent to false and EditType to Row. This allows me to add a record inline, but disables the ability to edit already existing records.

<telerik:RadGrid ID="RadGridActionItem" runat="server" AllowSorting="True" AllowPaging="true"
    AllowFilteringByColumn="True" OnNeedDataSource="RadGridActionItem_NeedDataSource"
    OnPageIndexChanged="RadGridActionItem_PageIndexChanged" OnItemCreated="RadGridAction_ItemCreated"
    OnDeleteCommand="RadGridActionItem_DeleteCommand" OnInsertCommand="RadGridActionItem_InsertCommand"
    OnBatchEditCommand="RadGrid1_BatchEditCommand" AllowAutomaticUpdates="True" AllowMultiRowEdit="True" OnItemDataBound="RadGridActionItem_ItemDataBound"
    Width="80%" HorizontalAlign="Center" PageSize="15" EnableViewState="true" Skin="Windows7">
    <GroupingSettings CaseSensitive="false" />
    <MasterTableView AutoGenerateColumns="false" ShowFooter="true" DataKeyNames="Action_Item_Id"
        ClientDataKeyNames="Action_Item_Id" CommandItemDisplay="Top" Width="100%" HorizontalAlign="Center"
        EditMode="Batch">
        <BatchEditingSettings OpenEditingEvent="None" EditType="Row"/>

What is the best way to add validation to multiple fields within the new inline add record? I have used the following example to validate one field, but I get errors when attempting to use the same format for multiple fields.

<telerik:GridBoundColumn DataField="ProductName" HeaderStyle-Width="210px" HeaderText="ProductName" SortExpression="ProductName"
    UniqueName="ProductName">
    <ColumnValidationSettings EnableRequiredFieldValidation="true">
        <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">
        </RequiredFieldValidator>
    </ColumnValidationSettings>
</telerik:GridBoundColumn>

How can I use this to validate other specific fields within the add new record row?

Thanks,
Matt
0
Angel Petrov
Telerik team
answered on 22 Aug 2014, 12:27 PM
Hi Matt,

Generally you should be able to validate all the fields in the new row by following the illustrated approach and it is rather strange that an error is thrown. Could you please elaborate more on the exact type of error? Additionally please share with us the entire page contents(markup and code-behind) so we could examine the implementation. That would greatly facilitate us in providing a precise answer on why this behavior occurs.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Matthew
Top achievements
Rank 1
Answers by
Matthew
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or