jQWidgets Forums

jQuery UI Widgets Forums Grid jqxGrid Column Dropdown Binding

This topic contains 5 replies, has 2 voices, and was last updated by  Dimitar 10 years, 11 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • jqxGrid Column Dropdown Binding #52510

    kkochhar
    Participant

    Hello,

    I am binding a Grid column type dropdown through a source. When the page is loaded the dropdown is binded correctly. However when I add a new blank row the binding of dropdown with the source doesn’t happen. How would you add a new blank row so that dropdown is binded to the source?

    Thanks,
    Kunal

    jqxGrid Column Dropdown Binding #52514

    kkochhar
    Participant

    It throws following error when a new blank row is added and when you click on the dropdown list to bring it in edit mode:

    Uncaught TypeError: Object [object Number] has no method ‘replace’

    jqxGrid Column Dropdown Binding #52515

    kkochhar
    Participant

    Anyone there to help? Following is the code for binding dropdown of grid column:

    text: 'Client', columntype: 'dropdownlist', datafield: 'Client', width: '15%',
                                  createeditor: function (row, cellvalue, editor) {
                                      console.log(clientSourceDA);
                                      editor.jqxDropDownList({ displayMember: 'Title', valueMember: 'Title', source: clientSourceDA });
                                  }

    I am constructing data in clientSourceDA on page load and keeping it cached. However as soon as I add new row with following code the dropdown doesn;t have anything and it throws javascript error as mentioned above.
    $(“#addProjectButton”).on(‘click’, function () {
    var datarow = generaterow();
    var commit = $(“#jqxprojectgrid”).jqxGrid(‘addrow’, null, datarow, top);
    });

    var generaterow = function (i) {
    var row = {};
    row[“Title”] = “”;
    row[“ProjectCode”] = “”;
    row[“Client”] = “”;
    row[“Billable”] = “”;
    row[“NonBillable”] = “”;
    row[“Comments”] = “”;
    row[“Members”] = “”;
    return row;
    }

    jqxGrid Column Dropdown Binding #52525

    kkochhar
    Participant

    Guys, I have hit the brick wall PLEASE HELP!!!

    jqxGrid Column Dropdown Binding #52540

    kkochhar
    Participant

    Bump! Doh! Anyone out there to assist?

    jqxGrid Column Dropdown Binding #52551

    Dimitar
    Participant

    Hello kkochhar,

    We could not reproduce the reported issue with the following example. Please make sure you are using the latest version of jQWidgets (3.2.2).

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcombobox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script>
        <script type="text/javascript" src="../../scripts/demos.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                // prepare the data
                var ordersSource =
                {
                    datatype: "xml",
                    datafields: [
                        { name: 'ShippedDate', map: 'm\\:properties>d\\:ShippedDate', type: 'date' },
                        { name: 'Freight', map: 'm\\:properties>d\\:Freight', type: 'float' },
                        { name: 'ShipName', map: 'm\\:properties>d\\:ShipName', type: 'string' },
                        { name: 'ShipAddress', map: 'm\\:properties>d\\:ShipAddress', type: 'string' },
                        { name: 'ShipCity', map: 'm\\:properties>d\\:ShipCity', type: 'string' },
                        { name: 'ShipCountry', map: 'm\\:properties>d\\:ShipCountry', type: 'string' }
                    ],
                    root: "entry",
                    record: "content",
                    id: 'm\\:properties>d\\:OrderID',
                    url: "../sampledata/orders.xml",
                    pager: function (pagenum, pagesize, oldpagenum) {
                        // callback called when a page or page size is changed.
                    },
                    updaterow: function (rowid, rowdata, result) {
                        // synchronize with the server - send update command
                        // call result with parameter true if the synchronization with the server is successful 
                        // and with parameter false if the synchronization failder.
                        result(true);
                    }
                };
                var ordersAdapter = new $.jqx.dataAdapter(ordersSource);
                var list = ['Germany', 'Brazil', 'France'];
                $("#jqxgrid").jqxGrid(
                {
                    width: 850,
                    source: ordersAdapter,
                    selectionmode: 'singlecell',
                    editable: true,
                    pageable: true,
                    autoheight: true,
                    columns: [
                        {
                            text: 'Ship Country', datafield: 'ShipCountry', width: 150, columntype: 'dropdownlist',
                            createeditor: function (row, column, editor) {
                                editor.jqxDropDownList({ autoDropDownHeight: true, source: list });
                            }
                        },
                        { text: 'Ship Name', datafield: 'ShipName' }
                    ]
                });
                $("#addRow").click(function () {
                    var row = {};
                    row["ShipCountry"] = "";
                    row["ShipName"] = "";
                    $("#jqxgrid").jqxGrid('addrow', null, row);
                });
            });
        </script>
    </head>
    <body class='default'>
        <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
            <div id="jqxgrid">
            </div>
            <br />
            <button id="addRow">
                Add new row</button>
        </div>
    </body>
    </html>

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.