jQuery UI Widgets Forums Grid Adding additional column in a Grid not working

This topic contains 1 reply, has 2 voices, and was last updated by  Christopher 8 years, 10 months ago.

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

  • walker1234
    Participant

    I am trying to add an additional “Description” column as shown in the JSFiddle here and it’s not working. It’s blank right now. What am I doing wrong?

    Thanks


    Christopher
    Participant

    Hi walker1234,

    You’re not adding the data for the “description” to your array. You’re only adding the item itself and the date, but not the description. Here’s how it should look:

    
       for (var i = 0; i < data.length; i++) {
                    if (i == 0) {
                        var newItem = {};
                        newItem.key = data[i].name;
                        newItem.dates = [data[i].date];
                        newItem.description = data[i].description; //new
                        array.push(newItem);
                    } else {
                        var item = data[i];
                        var itemName = item.name;
                        var itemDate = item.date;
                        var itemDescription = item.description; //new
                        if (isUsedKey(array, itemName)) {
                            for (var j = 0; j < array.length; j++) {
                                if (array[j].key == itemName) {
                                    var index = array[j].dates.length;
                                    array[j].dates[index] = itemDate;
                                }
                            }
                        } else {
                            var nextNewItem = {};
                            nextNewItem.key = itemName;
                            nextNewItem.dates = [itemDate];
                            nextNewItem.description = itemDescription; //new
                            array.push(nextNewItem);
                        }
                    }
                }
    

    And here’s a fiddle link with the changes:
    https://jsfiddle.net/7ucvy5yr/66/

    Best Regards,
    Christopher

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.