removing a row / redrawing table doesn't update row count

removing a row / redrawing table doesn't update row count

VexiphneVexiphne Posts: 3Questions: 0Answers: 0
edited November 2010 in Bug reports
How can I get the row count to update when you delete rows from a datatable ?

Replies

  • jtaljtal Posts: 1Questions: 0Answers: 0
    Did you ever get a response to this? It is happening for me as well. I'm using 1.7 and when I do fnDeleteRow the row is removed from the table but the count stays the same.
  • verevere Posts: 4Questions: 0Answers: 0
    Same issue here.
  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin
    I'd guess you are using server-side processing. Is that correct? If so, then you should note that fnDeleteRow is suitable for client-side processing only - if you are using server-side processing (i.e. "bServerSide": true), then to add data, you must add it to the data source, i.e. the server-side, through an Ajax call.

    If you aren't using server-side processing, please link me to a test page so I can see the issue.

    Allan
  • jzesahnjzesahn Posts: 1Questions: 0Answers: 0
    I'm having a similar issue - I have a few drop downs that filter the data in my table on the client side based on a css class name applied to each row on the server side. The logic with this filtering can only be done on the server side, so I applied css class names to match the item in the drop down with the class. I'm caching the tr's with javascript since i have 2000+ rows, then showing/hiding rows in the drop down's .change event with display: none using an array.

    Here's an example (#issueBody is the table's );
    [code]
    // Since ddlPriority is data base driven, dynamically build class selectors
    var $priority0 = $('tr', '#issueBody');
    var priorities = { priority0: $priority0 };
    $("#ddlPriority > option").each(function () {
    if ($(this).attr('class') != 'priority0') {
    var style = $(this).attr('class');
    var $tr = $('tr.' + style, '#issueBody');
    priorities[style] = $tr;
    }
    });
    $('#ddlPriority').change(function (e) {
    e.preventDefault();
    var select = e.target;
    var option = select.options[select.selectedIndex];
    var filter = $(option).attr('class');
    $priority0.addClass('priorityFilter');
    priorities[filter].removeClass('priorityFilter');
    });
    [/code]

    The priorityFilter class is simply display: none. The options are priority0, priority1... priority[n] based on a database table's values. There's another one that does the same thing, so the filtering of both are applied to the table.

    How can I get the table row count to update when I perform this filtering? Is there a better way to do this to be compatible with DataTables?

    Thanks!
    Jason
This discussion has been closed.