jQWidgets Forums

jQuery UI Widgets Forums Grid rowexpand index different than initrowdetails index

This topic contains 1 reply, has 1 voice, and was last updated by  mircea.ontanu 8 years, 3 months ago.

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

  • mircea.ontanu
    Participant

    Hi,

    I have an issue with refreshing data in row details in jqxGrid.
    For each row detail initialized in initrowdetails, I’m adding a new dataAdapter to an array of adapters based on the row Index provided by initrowdetails:

    
    var initrowdetails = function (index, parentElement, gridElement, datarecord) {
            var _dataSourceComments =
            {
                dataType: "json",
                dataFields: [
                    { name: 'chatID', type: 'number' },
                    { name: 'createdDate', type: 'date' },
                    { name: 'text', type: 'string' },
                    { name: 'UserName', type: 'string' }
                ],
                id: 'chatID',
                url: _url + 'Workbook/GetRecordComments/' + datarecord.recordID
            };
    
            _recordCommentsDataAdapter = new $.jqx.dataAdapter(_dataSourceComments, {
                loadComplete: function (records) {
                    refreshCommentsPanel(index);
                },
                loadError: function (jqXHR, status, error) {
                    alert(error);
                }
            });
    
            _arrayRowDetailsCommentsAdapters[index] = _recordCommentsDataAdapter
            _recordCommentsDataAdapter.dataBind();
    
    ...
    

    What I am trying to do, is update the adapter in the rowexpand event just like this:

    
        $('#_gridRecords').on('rowexpand', function (event) {
            var args = event.args;
            //var details = args.details;
            var rowBoundIndex = args.rowindex;
    
            var _panelComments = _arrayRowDetailsCommentPanels[rowBoundIndex];
            if (_panelComments)
                _arrayRowDetailsCommentsAdapters[rowBoundIndex].dataBind();
    
            var _adapterInfoDetails = _arrayRowDetailsAdapters[rowBoundIndex];
            if (_adapterInfoDetails)
                _adapterInfoDetails.dataBind();
        });
    

    The issue is that the row index from the rowexpand event is not the same as the row index from the initrowdetails!

    If you have a filter / sorted grid / added groups then everything is not working. The rowexpand row index is actually the row number from the top of the grid to that specific row.
    That means it will also count the rows that are actually groups headers.
    Also if you have the grid sorted in some way, the same issue occurs, row indexes from rowexpand are just the row positions into the grid, and not actually the real row index.

    You can see this here:
    http://jsfiddle.net/qkzdq5bj/

    When you expand a row, you will see the Index from the inirowdetails and under the grid is written the index from the rowexpand event.
    How can I find the real row index in order to refresh my adapters from the array?

    Thanks,
    Mircea


    mircea.ontanu
    Participant

    Hi,

    I solved this myself.
    You have to use the getrowboundindex method in order to get the real ID of the row.

    var index = $('#_gridRecords').jqxGrid('getrowboundindex', rowBoundIndex);

    I hope this helps.

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

You must be logged in to reply to this topic.