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

[Solved] Grid batch update

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Start Informatica
Top achievements
Rank 1
Start Informatica asked on 26 Mar 2015, 11:05 AM
Hello,

I am using a grid connected to a wcf service like this:

dataSource: {                           
            transport: {
                read: {
                    url: "http://localhost:52916/Service1.svc/getdocumentdetail/"+e.data.SaleDocId,
                    dataType: "json",
                    type: "GET"
                },
                update: {
                    url: "http://localhost:52916/Service1.svc/updateDocumentDetails",
                    dataType: "json",
                    type: "POST"
                },
                parameterMap: function(data, operation) {
                            if (operation != "read") {
                                // web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
                                return JSON.stringify({ docLines: data.models })
                            } else {
                                return JSON.stringify(data);
                            }
                        }
            },
            schema: {
                data: "GetDocumentDetailResult",
                total: "GetDocumentDetailResult.length",
                model: {
                    id: "SaleDocId",
                    fields: {
                        SaleDocId: { type: "number", editable: false, nullable: true},
                        Line: { type: "number", editable: false},
                        Item: {type: "string", editable: false},
                        Location: { type: "string", editable: false},
                        Description: {type: "string", editable: false},
                        Qty: {type: "number", editable: true, validation: { min: 0}},
                        ItemWeight: { type: "number", editable: true, validation: { min: 0}},
                        GrossWeight: { type: "number", editable: false}
                    }
                }
            },


My Service looks like this:

<OperationContract>
    <WebInvoke(Method:="POST", ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped, UriTemplate:="updateDocumentDetails")>
    Function UpdateDocumentDetails(ByVal docLines As IEnumerable(Of wsDocumentDetail))

The wsDocumentDetail object is this:

<DataContract()> _
Public Class wsDocumentDetail
    Inherits wsDocument
 
    Private m_Description As String = String.Empty
    Private m_Item As String = String.Empty
    Private m_Line As Integer = 0
    Private m_Qty As Integer = 0
    Private m_GrossWeight As Double = 0
    Private m_ItemWeight As Double = 0
    Private m_Location As String = String.Empty
    Private m_QtaSede As Integer = 0
    Private m_Payment As String = String.Empty
    Private m_Port As String = String.Empty
    Private m_NoOfPacks As Integer = 0
    Private m_Carrier1 As String = String.Empty
    Private m_ShipToAddress As String = String.Empty
    Private m_Transport As String = String.Empty
 
.... all the get; set;


My update function:

Public Function UpdateDocumentDetails(ByVal docLines As IEnumerable(Of wsDocumentDetail)) Implements IService1.UpdateDocumentDetails
 
'Do stuff here
 
end function

Now, when i click on Save changes i get a 400 bad request and i think this is the line causing all the problems
return JSON.stringify({ docLines: data.models })

I tried changing it but when debugging the docLines object remains empty.

Could you please tell me what am i doing wrong.

Thank you.

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 30 Mar 2015, 08:30 AM
Hi,

I'm afraid it is not clear what exactly is the cause for the error you are getting by looking at the provided information. I suspect it is due to a misconfiguration of the web service. Therefore, please provide a small runnable sample in which the issue can be observed locally.

Also you may check this sample project which implements the similar scenario.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Start Informatica
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or