Giter VIP home page Giter VIP logo

Comments (3)

VictorioBerra avatar VictorioBerra commented on May 28, 2024

I want to add that I know I can use all sorts of manual overrides of columnDefs.data and datatables.ejax (jQuery ajax). However, I do not like how my callers need to know about the EF entity!

For example, this is currently a really dirty "fix"

DataTables Options

ajax: {
    url: editorRestURL,
    type: "POST",
    contentType: "application/json",
    data: function (d) {

        // Do not mutate d
        var payload = $.extend({}, d);

        for (var i = 0; i < payload.columns.length; i++) {
            var column = payload.columns[i];

            //...

            // Handle when column is an object with an `entity` property
            if (column.data && column.data.hasOwnProperty('entity')) {
                column.data = column.data.entity;
            }

        }

        return JSON.stringify(payload);
    }
},
columnDefs: [
    {
        "targets": "InventoryServerInventoryServerWarrantyLines",
        "data": {
            "_": "InventoryServers",
            "entity": "InventoryServerInventoryServerWarrantyLines"
        },
        "createdCell": function (td, cellData, rowData, row, col) {
            $(td).html(rowData.InventoryServers
                .map(function (server) {
                    return `${server.Name} (${server.SerialNumber})`;
                })
                .join(`,<br />`));
        }
    }
]

I have to add my own entity property to columnDefs.data so I can make sure the ajax call submits a property the server understands (because DTQ makes me configure searches against entity properties only) and for everything else I use the built in "_" so jQuery DT can use the property on the JSON (the ViewModel)

Its been difficult to have the clients be aware of the EF entites for requests and then our domain objects (viewmodels) for responses. They should not hve to be aware of the entities.

from datatables.queryable.

AlexanderKrutov avatar AlexanderKrutov commented on May 28, 2024

I think it's better to add some configuration property to DataTablesRequest which will indicate processing order for the data and name parameters.
Something like this:

public enum PropertyNameProcessingOrder
{
  DataAndName, // this is default as now
  NameAndData,
  DataOnly,
  NameOnly
}

from datatables.queryable.

VictorioBerra avatar VictorioBerra commented on May 28, 2024

@AlexanderKrutov That is a great idea.

from datatables.queryable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.