We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I utilize the datamanager query in the grid?

I've got something like this:

var dm = ej.DataManager({ url: "http://localhost:65055/odata/ArticleApi", adaptor: new ej.ODataV4Adaptor() });
        $("#Grid").ejGrid({
            dataSource: dm
        });

But now I want tot use the query of the datamanager as a datasource for the grid to narrow the selection and expand some objects. How can I do this? The examples show how to do it in the done event of the executeQuery command, but I want it the other way around to keep the benefits of using the grid with a datasources.

4 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team April 6, 2016 09:05 AM UTC

Hi Wouter,

Thanks for contacting Syncfusion support.

To process the data based on the query, we suggest you to use query API of ejGrid.

Please find the code example and sample:

<div id="FlatGrid">

</div>


<script type="text/javascript">

    var dm = ej.DataManager({ url: "/odata/Orders", adaptor: new ej.ODataV4Adaptor() });

    var query = ej.Query().where("EmployeeID", ej.FilterOperators.equal, 2, false);

        $("#FlatGrid").ejGrid({

            dataSource: dm,

            query : query,

            allowPaging: true,

            columns: [

                { field: "OrderID", headerText: "Order ID", isPrimaryKey: true },

                { field: "CustomerID", headerText: "Customer ID" },

                { field: "EmployeeID", headerText: "Employee ID" },

                { field: "ShipCountry", headerText: "Ship Country" },

                { field: "ShipCity", headerText: "Ship City" }

            ]

        });


</script>


Refer to the Help document for the ejQuery

http://help.syncfusion.com/js/api/ejquery

Regards,
Prasanna Kumar N.S.V



PK Prasanna Kumar Viswanathan Syncfusion Team April 6, 2016 09:17 AM UTC

Hi Wouter,

Please ignore the previous update.

To process the data based on the query, we suggest you to use query API of ejGrid.

Please find the code example and sample:

<div id="FlatGrid">

</div>


<script type="text/javascript">

    var dm = ej.DataManager({ url: "/odata/Orders", adaptor: new ej.ODataV4Adaptor() });

    var query = ej.Query().where("EmployeeID", ej.FilterOperators.equal, 2, false);

        $("#FlatGrid").ejGrid({

            dataSource: dm,

            query : query,

            allowPaging: true,

            columns: [

                { field: "OrderID", headerText: "Order ID", isPrimaryKey: true },

                { field: "CustomerID", headerText: "Customer ID" },

                { field: "EmployeeID", headerText: "Employee ID" },

                { field: "ShipCountry", headerText: "Ship Country" },

                { field: "ShipCity", headerText: "Ship City" }

            ]

        });


</script>


Sample: http://www.syncfusion.com/downloads/support/forum/123632/ze/EJGrid949924602

Refer to the Help document for the ejQuery

http://help.syncfusion.com/js/api/ejquery

Regards,
Prasanna Kumar N.S.V


WO Wouter April 6, 2016 09:20 AM UTC

Thanks! Scrolled that page from top to bottom but missed it. So much options...


PK Prasanna Kumar Viswanathan Syncfusion Team April 7, 2016 09:49 AM UTC

Hi Wouter,

We are happy to hear that your issue has been resolved.

Please let us know if you need any further assistance.

Regards,
Prasanna Kumar N.S.V

Loader.
Live Chat Icon For mobile
Up arrow icon