how to display columns as rows in ListGrid in Smart gwt?

有些话、适合烂在心里 提交于 2020-01-06 03:53:24

问题


I am a new bee to Smart gwt. Basically I have my data structure as:

A
|_____ B1

  |__C1
  |__C2
  |__C3

|_ B2

So i have created my ListGridRecord as follows:

public class VEPAreaRecord extends ListGridRecord{

public VEPAreaRecord(){

}


/**
 * @param vepAreaName
 * @param checkStations
 */
public VEPAreaRecord(String vepAreaName, String[] checkStations) {
    setVepAreaName(vepAreaName);
    setCheckStations(checkStations);
}


/**
 * @return the vepAreaName
 */
public final String getVepAreaName() {
    return getAttribute("vepAreaName");
}
/**
 * @param vepAreaName the vepAreaName to set
 */
public final void setVepAreaName(String vepAreaName) {
    setAttribute("vepAreaName",vepAreaName);
}
/**
 * @return the checkStations
 */
public final String[] getCheckStations() {
    return getAttributeAsStringArray("checkStations");
}
/**
 * @param checkStations the checkStations to set
 */
public final void setCheckStations(String[] checkStations) {
    setAttribute("checkStations",checkStations);
}

}

But in my ListGrid I want tp show my data as

Area1 Area2 Area3

Check1 check2 chek3

check4

check5

So basically what i want is to display my rows as columns and vice-versa. But I dont know how to acheive this. Or is there any other component which takes care of this?


回答1:


Yes CubeGrid is available to Power and Enterprise license holders from Isomorphic. Check out the CubeGrid and Facets classes and take a look at the show cases on the smartgwt pages.

http://www.smartclient.com/smartgwtee/showcase/#cube_analytics and follow examples.

If you are just able to use ListGrid you can achieve the same thing through iterating through the records. If you are able to use a database you can enter customSQL

such as:

<operationBindings>
<operationBinding operationType="fetch" operationId="VEP_AREA_RECORD">

<customSQL>

SELECT * FROM (SELECT SUBSTRING(MeasurementTime,7,4) [Year], CASE SUBSTRING(Time,1,2) WHEN '01' THEN 'Jan' WHEN '02' THEN 'Feb' WHEN '03' THEN 'Mar' WHEN '04' THEN 'Apr'  WHEN '05' THEN 'May' WHEN '06' THEN 'Jun' WHEN '07' THEN 'Jul' WHEN '08' THEN 'Aug' WHEN '09' THEN 'Sep'  WHEN '10' THEN 'Oct'  WHEN '11' THEN 'Nov'  WHEN '12'THEN 'Dec' END as [Month],      [value] , [col1] as col1,
  col1 [col1_name], col2 [col2_name], col3 [col3], [col4_name] FROM your_table  WHERE MeasurementValue IS NOT NULL) TableDate  PIVOT <what you want in rows>  FOR [Month] IN (
    [Jan],[Feb],[Mar],[Apr],
    [May],[Jun],[Jul],[Aug],
    [Sep],[Oct],[Nov],[Dec]
  )
) AS PivotTable
 ORDER BY groupCol1, groupCol2

</customSQL>

clearly these columns could be actual values in your records/db or derived (in my case derived from the datefield. I"m not a SQL guru so if there's a better way I'd love to hear it.

In the above exmple the output would be

                           [jan]  [feb]  [mar]  etc.....in your case

[col1_valA] [col2_val1]    valx    valy
[col1_valB] [col2_val2


来源:https://stackoverflow.com/questions/10243466/how-to-display-columns-as-rows-in-listgrid-in-smart-gwt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!