jQWidgets Forums

jQuery UI Widgets Forums Grid issue with data Field name "Group" in JqxGrid

This topic contains 3 replies, has 2 voices, and was last updated by  alpesh 10 years, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • alpesh
    Participant

    Hello,

    We are getting issue with using datafield name Group.We are using below code,

     $(document).ready(function () {
                var theme = "";
                // prepare the data
                var data = new Array();
                var firstNames =
                [
                    "Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene"
                ];
    
                var group =
                [
                    "Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier"
                ];
                for (var i = 0; i < 200; i++) {
                    var row = {};
                    row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)];
                    row["group"] = group[Math.floor(Math.random() * group.length)];
                    data[i] = row;
                }
                var source =
                {
                    localdata: data,
                    datatype: "array",
                    datafields:
                    [
                        { name: 'firstname', type: 'string' },
                        { name: 'group', type: 'string' }
                       
                    ]
                };
                var dataAdapter = new $.jqx.dataAdapter(source);
                $("#jqxgrid").jqxGrid(
                {
                    width: 400,
                    source: dataAdapter,
                    theme: theme,
                    columnsresize: true,
                    columns: [
                      { text: 'Name', dataField: 'firstname', width: 200 },
                      { text: 'Group', dataField: 'group', width: 200 },
                    ]
                });
            });

    We are getting all rows blank.
    Could you please help us ?

    Thanks,
    Alpesh


    alpesh
    Participant

    Hello,
    Any help will be greatly appreciated!?

    Thanks,
    Alpesh

    issue with data Field name "Group" in JqxGrid #60041

    Dimitar
    Participant

    Hello Alpesh,

    “group” is a reserved word and you need to map the datafield, i.e.:

    $(document).ready(function () {
                var theme = "";
                // prepare the data
                var data = new Array();
                var firstNames =
                [
                    "Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene"
                ];
    
                var group =
                [
                    "Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier"
                ];
                for (var i = 0; i < 200; i++) {
                    var row = {};
                    row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)];
                    row["group"] = group[Math.floor(Math.random() * group.length)];
                    data[i] = row;
                }
                var source =
                {
                    localdata: data,
                    datatype: "array",
                    datafields:
                    [
                        { name: 'firstname', type: 'string' },
                        { name: 'group1', map: 'group', type: 'string', }
                       
                    ]
                };
                var dataAdapter = new $.jqx.dataAdapter(source);
                $("#jqxgrid").jqxGrid(
                {
                    width: 400,
                    source: dataAdapter,
                    theme: theme,
                    columnsresize: true,
                    columns: [
                      { text: 'Name', dataField: 'firstname', width: 200 },
                      { text: 'Group', dataField: 'group1', width: 200 },
                    ]
                });
            });

    Best Regards,
    Dimitar

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

    issue with data Field name "Group" in JqxGrid #60050

    alpesh
    Participant

    Thank you very much Dimitar.
    It’s working.

    Regards,
    Alpesh

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

You must be logged in to reply to this topic.