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

CommentFileSizeAuthor
#2 screenshot I.gif23.58 KBkasalla
#2 screenshot II.gif7.01 KBkasalla

Comments

heine’s picture

Status: Active » Postponed (maintainer needs more info)
kasalla’s picture

StatusFileSize
new7.01 KB
new23.58 KB

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

kasalla’s picture

No idea?

Max_Headroom’s picture

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!

wim leers’s picture

Title: How to sort table » Support for table sorting
Version: 5.x-1.x-dev » 6.x-1.x-dev
Category: support » feature
Status: Postponed (maintainer needs more info) » Postponed

I think you'll have to do the sorting yourself and then use #weight for each option inside #options.

Of course, this could be supported out of the box, but it'd be a new feature.

wim leers’s picture

Title: Support for table sorting » Document how to do table sorting
Component: Code » Documentation
Category: feature » task

Apparently, it's supported, but it's very poorly documented: http://heine.familiedeelstra.com/node/1428.

wim leers’s picture

Status: Postponed » Closed (duplicate)

Can now be considered a duplicate of #241697: Extended documentation on provided elements.

kasalla’s picture

Hey, thx for reply. I think we can close this one.
Using uasort() did it.