EditableOrder not defined

In several of the examples (https://ej2.syncfusion.com/aspnetmvc/documentation/grid/data-binding/#remote-save-adaptor I see EditableOrder as a type, but it says not defined, and I haven't been able to figure out where it's at so I can include the library.
I don't need a whole project, just the name of the library to import so that EditableOrder is defined.
Thanks


4 Replies

MS Manivel Sellamuthu Syncfusion Team June 24, 2021 03:56 AM UTC

Hi Customer, 

Greetings from Syncfusion support. 

EditableOrder is a class that is used deserialize the value from client to controller. Since it is just a class to deserialize values in the server side , we have not included in that in documentation.  You can use your use this class or you can create your own class. In the below documentation, we have used CRUDModel, which has the same definition like EditableOrder. Please find the below reference code for more information. 

public ActionResult Insert(CRUDModel Object) 
{ 
    var ord = Object.Value; 
    OrdersDetails.GetAllRecords().Insert(0, ord); 
    return Json(Object.Value); 
} 
 
public class CRUDModel 
{ 
    public List<OrdersDetails> Added { get; set; } 
 
    public List<OrdersDetails> Changed { get; set; } 
 
    public List<OrdersDetails> Deleted { get; set; } 
 
    public OrdersDetails Value { get; set; } 
 
    public int key { get; set; } 
     
    public string action { get; set; } 
} 


Please let us know if you need further assistance. 

Regards, 
Manivel 



JL jlwarranty June 26, 2021 08:18 AM UTC

Ok, that all makes sense now, and I put that in, but when I go to add a new line, or update an existing line, the Value is nothing (like null).


index.vbhtml:

    @Html.EJS().Grid("Grid").DataSource(Function(datamanager As DataManagerBuilder) ({datamanager.Json(ViewBag.DataSource.ToArray()).InsertUrl("/Home/Insert").RemoveUrl("/Home/Delete").UpdateUrl("/Home/Update").Adaptor("RemoteSaveAdaptor")})).Columns(Function(col As Object) {

                                    col.Field("JobCardLineID").HeaderText("ID").IsPrimaryKey(True).Visible(False).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(),

                                    col.Field("LineNum").HeaderText("Line Num").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(),

                                    col.Field("TotalAmt").HeaderText("Total Amount").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(),

                                    col.Field("StatusType").HeaderText("Status Type").Edit(New With {.create = "createStatusType", .read = "readStatusType", .destroy = "destroyStatusType", .write = "writeStatusType"}).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(),

                                    col.Field("LineDate").HeaderText("Line Date").Format("M/d/y").Edit(New With {.create = "createLineDate", .read = "readLineDate", .destroy = "destroyLineDate", .write = "writeLineDate"}).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(),

                                    col.Field("Notes").HeaderText("Notes").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(),

                                    col.Field("Adjustment").HeaderText("Adjustment?").Edit(New With {.create = "createAdjustment", .read = "readAdjustment", .destroy = "destroyAdjustment", .write = "writeAdjustment"}).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Add(),

                                    col.Field("ZeroDollar").HeaderText("Zero Dollar?").Edit(New With {.create = "createZeroDollar", .read = "readZeroDollar", .destroy = "destroyZeroDollar", .write = "writeZeroDollar"}).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Add()

                                }).EditSettings(Function(edit) {edit.AllowAdding(True).AllowEditing(True).AllowDeleting(True).Mode(Syncfusion.EJ2.Grids.EditMode.Normal)}).Toolbar(New List(Of String)({"Add", "Edit", "Delete", "Update", "Cancel"})).Render();



HomeController.vb:

    Public Function Update(<Microsoft.AspNetCore.Mvc.FromBody> value As iCRUDModel(Of JCLine)) As Mvc.ActionResult

        Try

            Dim jcl As JCLine = value.value

            Dim line As JCLine = lines.Where(Function(x) (x.JobCardLineID = jcl.JobCardLineID))

            line.LineNum = jcl.LineNum

            line.TotalAmt = jcl.TotalAmt

            line.StatusType = jcl.StatusType

            line.LineDate = jcl.LineDate

            line.Notes = jcl.Notes

            line.Adjustment = jcl.Adjustment

            line.ZeroDollar = jcl.ZeroDollar


            Return Json(lines)

        Catch ex As Exception

            Return Json(ex.Message)

        End Try

    End Function

    Public Function Insert(<FromBody> value As CRUDModel) As Mvc.ActionResult

        Return Json(lines)

    End Function


When I push the update button, this is the request payload that gets sent out:

{"value":{"JobCardLineID":23,"LineNum":"1","TotalAmt":"$67.40","StatusType":"Paid","LineDate":"2012-07-19T04:00:00.000Z","Notes":"","Adjustment":false,"ZeroDollar":false},"action":"update","keyColumn":"JobCardLineID","key":23}






JL jlwarranty June 27, 2021 09:07 PM UTC

Also, my CRUDModel classes:


Public Class CRUDModel

    Public Property Added As List(Of JCLine)

    Public Property Changed As List(Of JCLine)

    Public Property Deleted As List(Of JCLine)

    Public Property Value As JCLine

    Public Property key As Integer

    Public Property action As String

End Class

Public Class iCRUDModel(Of T)

    Public Property action As String

    Public Property table As String

    Public Property keyColumn As String

    Public Property key As Object

    Public Property value As T

    Public Property added As List(Of T)

    Public Property changed As List(Of T)

    Public Property deleted As List(Of T)

    Public Property params As IDictionary(Of String, Object)

End Class




MS Manivel Sellamuthu Syncfusion Team June 29, 2021 11:54 AM UTC

Hi Customer, 
 
Thanks for your update. 
 
We have prepared the sample based on your update and insert action is working fine at our end. Please refer the below screenshots and code example and sample for more information. 
 
 
 
 
 
 
<div class="control-section"> 
    @Html.EJS().Grid("Grid").DataSource(ds => ds.Url("/Home/UrlDatasource") 
.Adaptor("UrlAdaptor").InsertUrl("/Home/Insert").RemoveUrl("/Home/Remove").UpdateUrl("/Home/Update")).Columns(col => 
{ 
 
. . .Render() 
</div> 
 
Namespace mvc_ej2.Controllers 
    Public Class HomeController 
        Inherits Controller 
 
        Public Shared orddata As List(Of OrdersDetails) = New List(Of OrdersDetails)() 
 
        Public Function Index() As ActionResult 
            If orddata.Count() = 0 Then BindData() 
            ViewBag.datasource = orddata.ToArray() 
            Return View() 
        End Function 
 
        Public Sub BindData() 
            Dim code As Integer = 10000 
 
            For i As Integer = 1 To 10 - 1 
                Call orddata.Add(New OrdersDetails(code + 2"ANATR", i + 03.3 * i, TrueNew DateTime(199572235), "Madrid""Queen Cozinha""Brazil"New DateTime(1996911), "Avda. Azteca 123")) 
                Call orddata.Add(New OrdersDetails(code + 3"ANTON", i + 14.3 * i, TrueNew DateTime(20121225235), "Cholchester""Frankenversand""Germany"New DateTime(1996107), "Carrera 52 con Ave. Bolívar #65-98 Llano Largo")) 
                Call orddata.Add(New OrdersDetails(code + 4"BLONP", i + 25.3 * i, FalseNew DateTime(20021225235), "Marseille""Ernst Handel""Austria"New DateTime(19961230), "Magazinweg 7")) 
                Call orddata.Add(New OrdersDetails(code + 5"BOLID", i + 36.3 * i, TrueNew DateTime(195302180524), "Tsawassen""Hanari Carnes""Switzerland"New DateTime(1997123), "1029 - 12th Ave. S.")) 
                code += 5 
            Next 
        End Sub 
 
        Public Function UrlDatasource(ByVal dm As TestDm) As ActionResult 
            Dim DataSource As IEnumerable = orddata.ToList() 
            Dim operation As DataOperations = New DataOperations() 
 
            If dm.Search IsNot Nothing AndAlso dm.Search.Count > 0 Then 
                DataSource = operation.PerformSearching(DataSource, dm.Search)  'Search 
            End If 
 
            If dm.Sorted IsNot Nothing AndAlso dm.Sorted.Count > 0 Then 'Sorting 
                DataSource = operation.PerformSorting(DataSource, dm.Sorted) 
            End If 
 
            If dm.Where IsNot Nothing AndAlso dm.Where.Count > 0 Then 'Filtering 
                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where(0).[Operator]) 
            End If 
 
            Dim count As Integer = DataSource.Cast(Of OrdersDetails)().Count() 
 
            If dm.Skip <> 0 Then 
                DataSource = operation.PerformSkip(DataSource, dm.Skip)   'Paging 
            End If 
 
            If dm.Take <> 0 Then 
                DataSource = operation.PerformTake(DataSource, dm.Take) 
            End If 
 
            Return If(dm.RequiresCounts, Json(New With { 
                .result = DataSource, 
                count 
            }), Json(DataSource)) 
        End Function 
 
        Public Function Update(ByVal myObject As CRUDModel(Of OrdersDetails)) As ActionResult 
            Dim ord = myObject 
            Dim val As OrdersDetails = orddata.Where(Function([or]) CBool([or].OrderID Is ord.Value.OrderID)).FirstOrDefault() 
 
            If val IsNot Nothing Then 
                val.OrderID = ord.Value.OrderID 
                val.EmployeeID = ord.Value.EmployeeID 
                val.CustomerID = ord.Value.CustomerID 
                val.Freight = ord.Value.Freight 
                val.OrderDate = ord.Value.OrderDate 
                val.ShipCity = ord.Value.ShipCity 
                val.ShipAddress = ord.Value.ShipAddress 
                val.ShippedDate = ord.Value.ShippedDate 
            End If 
 
            Return Json(ord.Value) 
        End Function 
 
        Public Function Insert(ByVal value As OrdersDetails) As ActionResult 
            Dim ord = value 
            orddata.Insert(0, ord) 
            Return Json(value) 
        End Function 
 
        Public Sub Remove(ByVal key As Integer) 
            Call orddata.Remove(orddata.Where(Function([or]) [or].OrderID = key).FirstOrDefault()) 
        End Sub 
 
        Public Class TestDm 
            Inherits DataManagerRequest 
 
            Public Property flag As Integer 
        End Class 
 
        Public Class CRUDModel 
            Public Property value As OrdersDetails 
            Public Property key As Integer 
            Public Property action As String 
            Public Property keycolumn As String 
        End Class 
 
        Public Class OrdersDetails 
            Public Sub New() 
            End Sub 
 
            Public Sub New(ByVal OrderID As IntegerByVal CustomerId As StringByVal EmployeeId As IntegerByVal Freight As DoubleByVal Verified As BooleanByVal OrderDate As DateByVal ShipCity As StringByVal ShipName As StringByVal ShipCountry As StringByVal ShippedDate As DateByVal ShipAddress As String) 
                Me.OrderID = OrderID 
                Me.CustomerID = CustomerId 
                Me.EmployeeID = EmployeeId 
                Me.Freight = Freight 
                Me.ShipCity = ShipCity 
                Me.Verified = Verified 
                Me.OrderDate = OrderDate 
                Me.ShipName = ShipName 
                Me.ShipCountry = ShipCountry 
                Me.ShippedDate = ShippedDate 
                Me.ShipAddress = ShipAddress 
            End Sub 
 
            Public Property OrderID As Integer? 
            Public Property CustomerID As String 
            Public Property EmployeeID As Integer? 
            Public Property Freight As Double? 
            Public Property ShipCity As String 
            Public Property Verified As Boolean 
            Public Property OrderDate As Date 
            Public Property ShipName As String 
            Public Property ShipCountry As String 
            Public Property ShippedDate As Date 
            Public Property ShipAddress As String 
        End Class 
    End Class 
End Namespace 
 
 
Please let us know if you need further assistance. 
 
Regards, 
Manivel 


Loader.
Up arrow icon