问题描述
例如我有这样的表
-------------------------------------- -------------------------
位置|尺寸| cont_no |价格|仓库| cond |
---------------------------------------------- -----------------
美国| XX | 123 | 230 | SED | LK |
美国| YY | 343 | 330 | ASD |香港|
阿联酋| XX | 233 | 230 | SED | LK |
IND | ZZ | 123 | 230 | SAD | FK |
IND | XX | 213 | 430 | ASD | KK |
IND | YY | 433 | 870 | GFD | FK |
美国| YY | 865 | 230 | SED | LK |
阿联酋| XX | 976 | 430 | SED |香港|
美国| ZZ | 342 | 230 | CCD |香港|
阿联酋| XX | 132 | 445 | SED | KK |
阿联酋| ZZ | 064 | 323 | YYD | LK |
IND | YY | 452 | 130 | ITG |香港|
---------------------------------------------- -----------------
这就是我需要分组上表
-------------------- -----------
位置| XX | YY | ZZ |
-------------------------------
阿联酋| 3 | 0 | 1 |
美国| 1 | 2 | 1 |
IND | 1 | 2 | 1 |
-------------------------------
我想根据位置和大小列进行分组,例如:美国有3个XX和0个YY和1个ZZ,
然后,当我点击该行我想展开并显示那些3 XX和0 YY和1 ZZ其他四列cont_no,价格,仓库,cond
请有人帮助我或给我一些建议或链接参考。
谢谢
我想这是你想要的!
检查以下问题和答案
JSFIDDLE
JSFIDDLE
How to collapse and expand the table based on multiple columns grouping.
For example I have table like this
---------------------------------------------------------------
location | size | cont_no | price | depot | cond |
---------------------------------------------------------------
USA | XX | 123 | 230 | SED | LK |
USA | YY | 343 | 330 | ASD | HK |
UAE | XX | 233 | 230 | SED | LK |
IND | ZZ | 123 | 230 | SAD | FK |
IND | XX | 213 | 430 | ASD | KK |
IND | YY | 433 | 870 | GFD | FK |
USA | YY | 865 | 230 | SED | LK |
UAE | XX | 976 | 430 | SED | HK |
USA | ZZ | 342 | 230 | CCD | HK |
UAE | XX | 132 | 445 | SED | KK |
UAE | ZZ | 064 | 323 | YYD | LK |
IND | YY | 452 | 130 | ITG | HK |
---------------------------------------------------------------
This is how I need to group the above table
-------------------------------
location | XX | YY | ZZ |
-------------------------------
UAE | 3 | 0 | 1 |
USA | 1 | 2 | 1 |
IND | 1 | 2 | 1 |
-------------------------------
I want to group based on location and size column, Eg: USA has 3 XX and 0 YY and 1 ZZ,
And then when i click the row i want to expand and show those 3 XX and 0 YY and 1 ZZ other four column cont_no, price, depot, cond
please someone help me or give me some suggestion or link for reference.
Thank you
I think this is what your trying to make !
check the following question and answer
DataTables hidden row details example - the table header is misplaced (test case attached)
JSFIDDLE Sample 1
JSFIDDLE Sample 2
这篇关于如何在jquery数据表中分组多个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!