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

Insert not firing for BatchMode editing

2 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
CDK
Top achievements
Rank 1
CDK asked on 08 Dec 2019, 09:00 PM

I am attempting to develop a solution based on the example provided at:

https://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-data-source-binding/defaultcs.aspx?product=clientdatasource

 

As such, I am using BatchMode editing,  binding a client datasource and all insert, update, delete done by calling Web Services from the clientside.

 

The grid is retrieving and displaying data successfully.  I can update records and delete records, with the respective Web Services being called to update and delete successfully.

 

However, when I "Add new record", type in values, and hit "Save Changes",  I can see in Chrome developer mode that there is no call to the Web Service so my data is not actually saved.  There are no errors in the console either.

 

   <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" AllowPaging="false" AllowSorting="true" AllowFilteringByColumn="false" ClientDataSourceID="RadClientDataSource1" >
        <MasterTableView ClientDataKeyNames="KeyName" EditMode="Batch" CommandItemDisplay="Top" BatchEditingSettings-HighlightDeletedRows="true" >
            <Columns>
                <telerik:GridBoundColumn DataField="KeyName" HeaderText="Parameter" DataType="System.String" HeaderStyle-Font-Bold="true" />
                <telerik:GridBoundColumn DataField="KeyValue" HeaderText="Value" DataType="System.String" HeaderStyle-Font-Bold="true" />
                <telerik:GridBoundColumn DataField="KeyType" HeaderText="Type" DataType="System.String" HeaderStyle-Font-Bold="true" />
                <telerik:GridBoundColumn DataField="Description" HeaderText="Description" DataType="System.String" HeaderStyle-Font-Bold="true" />
                <telerik:GridBoundColumn DataField="SplitPassword" HeaderText="Split Password" DataType="System.String" HeaderStyle-Font-Bold="true" />
                <telerik:GridClientDeleteColumn HeaderText="Delete" HeaderStyle-Width="70px" HeaderStyle-Font-Bold="true" />
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="500px" />
        </ClientSettings>
    </telerik:RadGrid>
 
    <telerik:RadClientDataSource ID="RadClientDataSource1" runat="server" AllowBatchOperations="true">
            <ClientEvents OnCustomParameter="ParameterMap" />
            <DataSource>
                <WebServiceDataSourceSettings BaseUrl="API/SysParm.asmx/">
                    <Insert Url="InsertSystemParameters" RequestType="Post" ContentType="application/json" DataType="JSON" />
                    <Select Url="GetSystemParameters" RequestType="Post" ContentType="application/json" DataType="JSON" />
                    <Update Url="UpdateSystemParameters" RequestType="Post" ContentType="application/json" DataType="JSON" />
                    <Delete Url="DeleteSystemParameters" RequestType="Post" ContentType="application/json" DataType="JSON" />
                </WebServiceDataSourceSettings>
            </DataSource>
            <Schema ResponseType="JSON" DataName="d" >
                <Model ID="KeyName">
                    <telerik:ClientDataSourceModelField FieldName="KeyName" DataType="String" />
                    <telerik:ClientDataSourceModelField FieldName="KeyValue" DataType="String" />
                    <telerik:ClientDataSourceModelField FieldName="Description" DataType="String" />
                    <telerik:ClientDataSourceModelField FieldName="KeyType" DataType="String" />
                    <telerik:ClientDataSourceModelField FieldName="SplitPassword" DataType="String"  />
                </Model>
            </Schema>
            <SortExpressions>
                <telerik:ClientDataSourceSortExpression FieldName="KeyName" SortOrder="Desc" />
            </SortExpressions>
    </telerik:RadClientDataSource>

 

 

 

This is an example of a record in the dataset:

 

{
    "d": [{
        "__type": "CAMAPI.SystemParameter",
        "KeyName": "AD_GROUPS_APP_ID",
        "KeyValue": "2",
        "Description": "",
        "KeyType": "APP_ID",
        "SplitPassword": ""
    }]
}

 

My ParameterMap function is as follows:

 

function ParameterMap(sender, args) {
    if (args.get_type() != "read" && args.get_data()) {
        var data = "{ \"parameters\": " + JSON.stringify(args.get_data().models) + "}";
        args.set_parameterFormat(data);
    }
}

 

 

Can you see anything to explain why inserts are not working?

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 11 Dec 2019, 11:35 AM

Hi,

 

Here are some suggestions which can help you resolve this issue:

1. Ensure that there are no hidden script errors:
https://www.telerik.com/support/kb/aspnet-ajax/ajaxmanager/details/get-more-descriptive-errors-by-disabling-ajax

2. I can see that there are some difference with the live demo sample. You can try changing these and see whether there is any change. The first one is this event handler:

<ClientEvents ... OnDataParse="Parse" />
3. The Next one are these:
            <Schema>
                <Model ID="CustomerID">
4. I am not familiar with your service, but you can compare it with the following:
    [WebGet]
    [AspNetCacheProfile("NoCache")]
    public CustomersResult InsertCustomers(string customersJSON)
    {
I hope these ideas will prove helpful in troubleshooting the problem.

 

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
CDK
Top achievements
Rank 1
answered on 17 Dec 2019, 07:41 PM

I had diverged from the example by removing the ReadOnly=true from the first column, as it is my intention for all displayed columns to be editable.

It appears this is not allowed, or else it breaks functionality.     I added a new column to act as the record id, with ReadOnly=true and Visible=false,  which is allowing the other columns to be editable and insert, update, delete all working fine.

Thanks.

 

Tags
Grid
Asked by
CDK
Top achievements
Rank 1
Answers by
Eyup
Telerik team
CDK
Top achievements
Rank 1
Share this question
or