Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
645
Save change IgGrid
posted

I have a igGrid, but the type of data which are not represented.
This occurs because the iggrid is updated and every time represents a different model.
When I want to save changes to the model, I can not, because I is not the model type.
To save the changes I have a function that I found in the documentation for Infragistics.
Is the next function:

Public Function EditingSaveChanges() As ActionResult
ViewData("GenerateCompactJSONResponse") = False
Dim m As New GridModel()
Dim transactions As List(Of Transaction(Of Object)) = m.LoadTransactions(Of Object)(HttpContext.Request.Form("ig_transactions"))
For Each t As Transaction(Of Object) In transactions
If t.type = "newrow" Then


ElseIf t.type = "deleterow" Then



ElseIf t.type = "row" Then

Next
Dim result As New JsonResult()
Dim response As New Dictionary(Of String, Boolean)()
response.Add("Success", True)
result.Data = response

Return result
End Function

This modified to receive anything, but I know the type of object that gets me.
Any way to get the type of which is the object that gets me?
when I do "t.row", I just say "object".

Thanks advances.

Best Regards.

Parents
No Data
Reply
  • 29417
    Offline posted

    Hello nitaGM ,

    Thank you for posting in our forum.

    You need to provide the type of the model when you load the transaction:

    Dim transactions As List(Of Transaction(Of YourModel))

    Otherwise the method will not be able to de-serialize the data the HttpContext.Request has returned((HttpContext.Request.Form("ig_transactions"))).

     

     Basically from the client side you’re passed a string that looks something like this: "[{\"type\":\"row\",\"tid\":\"e35b\",\"row\":{\"ProductID\":1,\"Name\":\"5\",\"ListPrice\":10,\"Name\":\"somename\"},\"rowId\":1}]"

    The client is of course not aware what model you have set for the grid so there’s no way to get that information from the request.

     

    You could manually keep track of which model the grid is currently using so that you can de-serialize updating request accordingly with the   LoadTransactions() method.

    Or you could manually de-serialize that object for example:

        List<Object> list = new JavaScriptSerializer().Deserialize<List<Object>>(HttpContext.Request.Form["ig_transactions"]);

    Which will give you a list of the key/value pair which you can then use to update your data .

     

    Let me know if you have any questions.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer

    Infragistics, Inc.

    http://ko.infragistics.com/support

     

Children