how to use Editor Server-Side MVC controller with existing collection, without using Database tables

how to use Editor Server-Side MVC controller with existing collection, without using Database tables

akuleshovaakuleshova Posts: 3Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • akuleshovaakuleshova Posts: 3Questions: 1Answers: 0

    I have collection of objects, I know how to use it with datatable, but i don't know how to use it with Editor, as in examples it is only using database connections and tables from database...

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Editor would always use objects - see example here. I'm not understanding your problem, so could you link to your page or create a test case, please.

    Colin

  • akuleshovaakuleshova Posts: 3Questions: 1Answers: 0

    here is from examples server-side:

            using (var db = new Database(settings.DbType, settings.DbConnection))
            {
                var response = new Editor(db, "datatables_demo")
                    .Model<StaffModel>()
                    .Field(new Field("first_name")
                        .Validator(Validation.NotEmpty())
                    )
                    .Field(new Field("last_name"))
                    .Field(new Field("extn")
                        .Validator(Validation.Numeric())
                    )
                    .Field(new Field("age")
                        .Validator(Validation.Numeric())
                        .SetFormatter(Format.IfEmpty(null))
                    )
                    .Field(new Field("salary")
                        .Validator(Validation.Numeric())
                        .SetFormatter(Format.IfEmpty(null))
                    )
                    .Field(new Field("start_date")
                        .Validator(Validation.DateFormat(
                            Format.DATE_ISO_8601,
                            new ValidationOpts { Message = "Please enter a date in the format yyyy-mm-dd" }
                        ))
                        .GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
                        .SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
                    )
                    .Process(request)
                    .Data();
    

    When i am filling datatable, i am returning JSON from controller, where filteredRecords is List<ModelView>

                var j = Json(new
                {
                    data = filteredRecords
                },
                JsonRequestBehavior.AllowGet);
    
                return j;
    

    How can i use new Editor() and populate data with my List<ModelView>, without db tables?

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    With our .NET server-side libraries you can't I'm afraid. They specifically require an ADO.NET connection to a database which is used for retrieving and storing data. They cannot be used on an arbitrary List.

    In terms of displaying the data, that should be readily possible by just returning your List as JSON to the client-side and configuring DataTables to use that JSON.

    However, writing updates from Editor would require more work since it would need to perform a lot of the work that the libraries we provide do via SQL (inserting, updating, etc).

    Allan

This discussion has been closed.