0

Question: I have a Data table displaying on django , but now I like to group by when ever I will hide the coloumn

column1 column2 column3

AAA CAD 25

AAA USD 12

BBB CAD 13

BBB USD 16

CCC CAD 11

CCC USD 18

The above table will be displayed on web page using Django, now when ever I hide coloumn2 It should group by and display like below table

column1 column3 AAA 37

BBB 29

CCC 39

when ever I unhide it again it should display same as first table again.

can anyone tell me there is any possible way to do it.

Thanks in advance.

sid
  • 31
  • 5
  • Can you post your models and template code here to make query? – Hardik Patel Dec 09 '15 at 15:33
  • models.py: DDAFULL(models.Model): LCR_CUSTOMER_TYPE=models.CharField(max_length=50,db_column='LCR_CUSTOMER_TYPE', primary_key=False) CUR=models.CharField(max_length=5) SIC_CODE=models.DecimalField(max_digits=6,decimal_places=0) LCR_NONOP_INS=models.DecimalField(max_digits=19,decimal_places=2) LCR_OP_INS=models.DecimalField(max_digits=19,decimal_places=2) LCR_NONOP_UNINS=models.DecimalField(max_digits=19,decimal_places=2) LCR_OP_UNINS=models.DecimalField(max_digits=19,decimal_places=2) – sid Dec 09 '15 at 15:39
  • views.py cursor1.execute('''SELECT * INTO table1 FROM (select dummy as LCR_CUSTOMER_TYPE,CUR AS CURRENCY, CONVERT(VARCHAR(20), CONVERT(MONEY, sum(LCR_NONOP_INS))) as LCR_NONOP_INS, CONVERT(VARCHAR(20), CONVERT(MONEY, sum(LCR_OP_INS))) as LCR_OP_INS, CONVERT(VARCHAR(20), CONVERT(MONEY, sum(LCR_NONOP_UNINS))) as LCR_NONOP_UNINS, CONVERT(VARCHAR(20), CONVERT(MONEY, sum(LCR_OP_UNINS))) as LCR_OP_UNINS from (select *,(case when LCR_CUSTOMER_TYPE='Corporate' then 'Non-Credit Financial Entities' else LCR_CUSTOMER_TYPE end) as dummy from table0) a group by CUR,dummy) tab1 ''') – sid Dec 09 '15 at 15:45
  • The table is displaying fine...but it should grouped by other columns on web page when ever I hide a column... @hardik Patel – sid Dec 09 '15 at 15:47

0 Answers0