How to sort table

anstosser - September 17, 2008 - 14:08
Project:Elements
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

Hello,

great module, but is there the possibility to sort the table?

Using this, breaks the table (it´s empty):

        array('data' => t('Cabin')),
        array('data' => t('Price'), 'field' => 'price', 'sort' => 'desc'),

greetz
Alex

#1

Heine - September 17, 2008 - 18:47
Status:active» postponed (maintainer needs more info)

http://heine.familiedeelstra.com/coding-help-tips

#2

anstosser - September 17, 2008 - 20:08

Ok, I try to make the issue more clear....

I want to set up a tableselect table via elements module.

The working code looks like this:

function mymodule_form(){

    $options = some_custom_code();   
    $header = array(
        'cabin' => t('Cabin'),
        'price' => t('Price'),
        );
    if (!empty($options)) {
        $form['attr']['attributes'] = array(
        '#type' => 'tableselect',
        '#header' => $header,
        '#options' => $options,
        '#advanced_select' => FALSE,
        '#multiple' => FALSE,
      );

}

The output is a it is supposed to be...S. screenshot I

Now I want to make the price sortable. Using common practice, it schould look like this:

function mymodule_form(){

     $options = some_custom_code();   
     $header = array(
        //EDIT
        array('data' => t('Kabine')),
        array('data' => t('Preis'), 'field' => 'price', 'sort' => 'desc'),
        //END EDIT
        );
    if (!empty($options)) {
        $form['attr']['attributes'] = array(
        '#type' => 'tableselect',
        '#header' => $header,
        '#options' => $options,
        '#advanced_select' => FALSE,
        '#multiple' => FALSE,
      );

}

In the second case the table itself is shown, but without the options. S. screenshot II

Needs still more info?
greetz
Alex

AttachmentSize
screenshot I.gif 23.58 KB
screenshot II.gif 7.01 KB

#3

anstosser - September 22, 2008 - 18:51

No idea?

#4

Max_Headroom - September 26, 2008 - 12:06

Sorry for pointing away from here, but maybe this might help: TAPIr
Docs here.
Have a look how you can show forms inside table. Maybe it will help you sort the fields?
I haven't tested it myself, I have also just read the docs.
Good luck!

 
 

Drupal is a registered trademark of Dries Buytaert.