This is a migrated thread and some comments may be shown as answers.

[Solved] Selected row to the top

0 Answers 191 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Garðar Valur
Top achievements
Rank 1
Garðar Valur asked on 23 Nov 2012, 02:33 PM
I have a Telerik MVC Grid and I want the selected to be forced on top of the list. I´m using DetailedView for the grid so it is collapse- and expandable. How would I force the selected row to the top of the list?

My Jquery:
function unit_onDetailViewExpand(e) {
    // Select the Grid
    var grid = $(this).data('tGrid');
    //Close all other rows
    grid.$rows().not(e.masterRow).each(function (index, row) {
        grid.collapseRow(row);
    });
 
    /* TODO: move row to the top, this hasn´t worked for me so far
    grid.reorderColumn(0, grid.columnFromTitle("Name"));
    $.telerik.trigger(grid.element, 'repaint');
    */
}

Thanx guys :)


### EDITED ###

I´ve managed to move the row to the top like this:

function onRowSelect(e){
    $(e.row).prependTo($(e.row).parent());
      var grid = $('#RentableUnits').data("tGrid");
      // get the first master table row
      var tr = $("#RentableUnits tbody > .t-master-row:eq(0)"); // use .t-master-row to select only the master rows

      // expand the row
      grid.expandRow(tr);
}

However I´m facing a new problem.  I´m using DetailedView and when I move the row to the top I still expand the old content within each row. If I were to move one row to the top, then expand it, the content of the "old" row is still there as the expanded content.

Any ideas?
Tags
Grid
Asked by
Garðar Valur
Top achievements
Rank 1
Share this question
or