koalyptus / HTML-Table-Filter-Generator

Filter HTML tables data easily
http://tablefilter.free.fr
19 stars 12 forks source link

Use custom_slc_options for more than one column #6

Closed answerquest closed 9 years ago

answerquest commented 9 years ago

It seems to work only when there's just one column number specified. Fails when I try to increase.

custom_slc_options: {  
        cols:[7],  
        texts: [['under 1L','1L - 10L','10L - 1Cr','1Cr - 10Cr','10Cr & above','not empty','empty']],  
        values: [  
            ['>=0 && <100000','>=100000 && <1000000','>=1000000 && <10000000','>=10000000 && <100000000','>=100000000','[nonempty]','[empty]']  
        ],  
        sorts: [false]  
    }, 

I tried a lot of tweaks to cols:[7], : cols:[6,7],, cols:[[6,7]],, cols:[[6],[7]],, etc... but none worked. In some cases the TableFilter loads properly with these columns' dropdowns staying the same default ones, in some cases the script crashes and the table loads as original html.

This would be for use cases where you have more than one column having numbers in the same ranges, like accounts records. But even in cases of different ranges, it would help to be able to define custom_slc_options for more than one column, right? I also tried to repeat the whole object again, Like:

custom_slc_options: { 
 { ..config for one column.. } , 
{ ..config for other column... } 
},

..and that gave me a SyntaxError: invalid property id

Oh, and the na, 'na expressions didn't work at my end.. I replaced them with [empty] and [nonempty] and they work properly. I had copied from this example: http://tablefilter.free.fr/datademo.htm

koalyptus commented 9 years ago

That's an example:

custom_slc_options: {
    cols: [3, 5],
    texts: [
        ['na', '0 - 50', '50 - 500', '500 - 15000', '15000 - 25000', '25000 - 100000', '100000 - 1500000', 'not na'],
        ['na', '0 - 50', '50 - 500', '500 - 15000', '15000 - 25000', '25000 - 100000', '100000 - 1500000', 'not na']
    ],
    values: [
        ['na', '>0 && <=50', '>50 && <=500', '>500 && <=15000', '>15000 && <=25000', '>25000 && <=100000', '>100000 && <=1500000', '!na'],
        ['na', '>0 && <=50', '>50 && <=500', '>500 && <=15000', '>15000 && <=25000', '>25000 && <=100000', '>100000 && <=1500000', '!na']
    ],
    sorts: [false, false]
},