Frage

I am new to Yii framework. I am analyzing autogenerated CRUD views. When I click column headers for sorting, it reloads data again, so it's much slower than writing jQuery way of sorting table. How to change that behavior. I do not want to reload data everytime I sort table, want to only sort what I have right now.

War es hilfreich?

Lösung

If I understand correctly, you want to sort only the rows in the current page, not all rows in the results set? I'm not sure I see the use in this unless it's a fairly small results set. Most users will want to see the whole results set ordered by the column and not just the single page.

There's nothing built into CGridView to do it on the client I don't think, but it wouldn't be hard to write one

$('table tr').each(function(){
    var me = $(this)
    if ( me.find('.columnToCompare').text() > me.find('.secondColumn').text() )
    {
         me.prev().insertBefore(me);
    }
}

Very quickly typed up, but you get the gist hopefully.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top