jQuery UI Widgets Forums Getting Started jqxgrid in MVC website

This topic contains 1 reply, has 1 voice, and was last updated by  jhhaidar 3 weeks, 3 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • jqxgrid in MVC website #120856

    jhhaidar
    Participant

    I am new on this website and my knowledge is limited

    I followed the example on this link

    https://www.jqwidgets.com/jquery-widgets-documentation/documentation/asp.net-integration/asp.net-mvc5.htm?search=
    I am seeing the data returned from the Controller OK in json format

    but index.cshtml is running on error on this line of code
    $(“#datatable”).jqxDataTable(

    Error: Invalid Selector! Please, check whether the used ID or CSS Class name is correct.

    at jQuery.fn.init.b.fn.<computed> [as jqxDataTable] (https://localhost:44337/Scripts/jqxcore.js:15:67403)

    at HTMLDocument.<anonymous> (https://localhost:44337/JHCustomers:126:29)

    the index.cshtml has these lines of code:

    @section scripts {
    <script>

    $(document).ready(function () {
    // prepare the data
    alert(‘all good’);

    var source =
    {
    dataType: “json”,
    dataFields: [
    { name: ‘CompanyName’, type: ‘string’ },
    { name: ‘ContactName’, type: ‘string’ },
    { name: ‘ContactTtile’, type: ‘string’ },
    { name: ‘Address’, type: ‘string’ }

    ],
    id: ‘CustomerID’,
    /*url: ‘/JHCustomers/GetCustomers’*/
    url: ‘https://localhost:44337/jhCustomers/getCustomers’
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    //Create Tree Grid
    $(“#datatable”).jqxDataTable(
    {
    width: 850,
    source: dataAdapter,
    theme: ‘arctic’,
    pageSize: 5,
    sortable: true,
    filterable: true,
    pageable: true,
    columns: [
    { text: ‘CompanyName’, dataField: ‘CompanyName’, width: 200 },
    { text: ‘ContactName’, dataField: ‘ContactName’, width: 200 },
    { text: ‘ContactTitle’, dataField: ‘ContactTitle’, width: 160 },
    { text: ‘Address’, dataField: ‘Address’, width: 200 }
    ]

    });

    });

    </script>

    }

    Please help

    jqxgrid in MVC website #120857

    jhhaidar
    Participant

    This issue is now working.
    no need to reply

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.