How to retrieve cell data from different table then current widget in icCube - iccube

In icCube reporting tool 6.1
is there a possibility to retrieve data like a cellValue(rowindex,columnindex) while i'm in a diffrent widget like chart box for example and wanna get a cell value from different table in the report? with Widget's JavaScript...? and also do other functions like column count or row count as i'm in the Widget's JavaScript of the actual table...?
UPDATED QUESTION
Example:
i wanna be able for example to get in the chart palette by Expression to
retrieve the number of the 1 row and column 2 (value 12)
and then for the example i wanna use this number and see if the number is greater then 10 then i will want the chart color to be Green and if less the blue... so i wanna know how to retrieve a specific cell from the table when the chart loads... and the chart will wait for a click on row from the table
so it will load after the table... so the rendering problem you've mentioned you have won't be a problem here.

You can share Table's data with global variable.
In On Data Received hook:
/**
* Return data object
*/
function(context, data, $box) {
window.ic3Data = {};
window.ic3Data.tableContext = context;
return data;
}
Then you can easily use PublicTableContext API from table widget in other charts. For example in a coloring expression for an AmChart:
return window.ic3Data.tableContext.cellValue(0,1) > 10 ? 'green' : 'red';

Related

Crossfilter total by group

Im trying to show the total number of people in each geography when they hover over using crossfilter, but my current code is only showing the total of all geographies. So what is the equivalent in crossfilter to the sql query: SELECT COUNT(*) GROUP BY dma
This is my code so far
//geography that is being hovered over, getting dma name and removing everything that is after the comma
sel_geog = layer.feature.properties.dma_1;
sel_geog = sel_geog.split(",")[0];
console.log(sel_geog);
//crossfilter to get total number of people of each geography
var dmaDim = voter_data.dimension(function(d) {return d.dma == sel_geog}),
dma_grp = dmaDim.groupAll().reduceCount().value();
console.log(dma_grp);
Crossfilter isn't meant to be used in a way where you are building new dimensions and groups for each user interaction. It's meant to build dimensions and groups before interactions take place and then update them quickly when filtering based on user interactions.
It's not really clear from this question what your data looks like or what you are trying to do, but you probably want to create dimensions and group for your dma property and then build your map based on that:
var voter_data = crossfilter(my_data);
var dmaDim = voter_data.dimension(function(d) { return d.dma; });
var dmaGroup = dmaDim.group();
At this point dmaGroup.all() will be an array of objects that looks like { key: 'dmaKey', value: 10 } where 10 is the count of all records where d.dma === 'dmaKey'. There are lots of ways you can aggregate differently with Crossfilter, but that may get you started.

Cant get ExtededDataGrid in Flex to filter with ComboBox on multiple columns

LATEST UPDATE: Issue answered here. Some one else at stackoverflow had a similar issue and it was resolved. Solution provided for convenience. This is the line of code I was missing:
comboHeaderColumn.useLabelFunctionForFilterCompare = true;
that line is followed by these:
comboHeaderColumn.filterComboBoxBuildFromGrid = true;
comboHeaderColumn.labelFunction = formatState;
where formatState is a local method that formats the data for the combobox.
UPDATE: I've now got the combobox's loading with the correct data, but when I select a value nothing happens. The combo boxes load only data that is in the column, and when you select a value in the combobox, it's supposed to filter the rows on that value. It doesn't.
Thanks for looking. I'm having trouble getting multiple filters to work in Flex in Flash Builder 4 using the ExtendedDataGrid and ComboBox's. Here is an image of part of the grid:
The User Name and City filter properly if you type text into the box's above the column header and the Request Date lets you select date ranges if you click on the Custom bar, but the Request Reason and State ComboBoxes do not list anything. I've created them using comboHeaderColumn.filterComboBoxBuildFromGrid = true; but all it does is put "[object Object]" as the only other selection under All.
I've used this article but it will only allow you to use a single filter for the entire grid.
My finished grid will have about 20 columns and from 20,000 to 450,000 rows of data so the filters are really important and I'll need more than one.
The code is very straight forward and loops through all the returned data and if the column is identified as a filter column it does this:
comboHeaderColumn.filterComboBoxDataProvider = codeValuePairs;
comboHeaderColumn.filterComboBoxLabelField = "Value";
comboHeaderColumn.filterControl = "ComboBox";
comboHeaderColumn.filterOperation = FilterExpression.FILTER_OPERATION_TYPE_EQUALS;
comboHeaderColumn.headerText = ac.Header;
comboHeaderColumn.dataField = ac.Name;
if( ac.Header == "State" || ac.Header == "Request Reason" )
{
comboHeaderColumn.filterComboBoxBuildFromGrid = true;
}
ProfileDataColumns.push(comboHeaderColumn);
This creates 2 entries in the combo box: All and [object Object]
What am I missing??? Anyway, after half a day searching I decided to reach out.
Any suggestions or direction to an article would be very much appreciated.
Thanks.

Flex mobile - How do I move to the next data in List.selectedItem when moving to next page?

When I move page01 to page02, I pass the same data along with it using the following code:
navigator.pushView(Page02, data);
How do I move to page02 with passing the next row of data (instead of the same data)?
In other word, how to increment to the next row of data with pushView?
Thanks.
If you have access to the List component which displays the data you want to pass into views, you can do something like this:
myList.dataProvider[myList.selectedIndex+1]
You'll want to do some checking to make sure that you're trying to reference an index that actually exists:
var mySelectedObject :Object;
if(myList.selectedIndex+1 < myList.dataProvider.length){
mySelectedObject = myList.dataProvider[myList.selectedIndex+1]
} else {
// do some other behaviour; such as selecting the first one in the list
mySelectedObject = myList.dataProvider[0]
}
navigator.pushView(page02, mySelectedObject );

Flex - sorting a datagrid column by the row's label

I'm creating a table that displays information from a MySQL database, I'm using foreignkeys all over the place to cross-reference data.
Basically I have a datagrid with a column named 'system.' The system is an int that represents the id of an object in another table. I've used lableFunction to cross-reference the two and rename the column. But now sorting doesn't work, I understand that you have to create a custom sorting function. I have tried cross-referencing the two tables again, but that takes ~30sec to sort 1200 rows. Now I'm just clueless as to what I should try next.
Is there any way to access the columns field label inside the sort function?
public function order(a:Object,b:Object):int
{
var v1:String = a.sys;
var v2:String = b.sys;
if ( v1 < v2 ){
trace(-1);
return -1;
}else if ( v1 > v2 ){
trace(1);
return 1;
}else {
trace(0);
return 0;
}
}
One way to handle this is to go through the objects you received and add the label as a property on each of them based on the cross-referenced id. Then you can specify your label property to display in your data grid column instead of using a label function. That way you would get sorting as you'd expect rather than having to create your own sort function.
The way that DataGrids, and other list based classes work is by using itemRenderers. Renderers are only created for the data that is shown on screen. In most cases there is a lot more data in your dataProvider than what is seen on screen.
Trying to sort your data based on something displayed by the dataGrid will most likely not give you the results you want.
But, there is no reason you can't call the same label function on your data objects in the sortFunction.
One way is to use the itemToLabel function of the dataGrid:
var v1:String = dataGrid.itemToLabel(a);
var v2:String = dataGrid.itemToLabel(b);
A second way is to just call the labelFunction explicitly:
var v1:String = labelFunction(a);
var v2:String = = labelFunction(b);
In my experience I have found sorting to be extremely quick, however you're recordset is slightly larger than what I usually load in memory at a single time.

how to show data at group level in flex advanced grid?

I am working on a grid example in flex using advanced grid control.
I know we can easily group data by specifying the field name.
At the group node level, other than the gorup name I want to be able to show data in the rest of the cells ( calculated data ) and I am looking for some dataRowBound event or similar to be able to hook some data in it.
Example: Grid displaying list of towns grouped by state. At the group level ( for each state) I want to show the total number of towns in each state. Here how can i show the total number in the town column.
You can do this by providing the data like this
<trade TrdId="Trade 1 o" col="0xCC9999" cmenu="YNYNYNYNYNYNYNY" AgreementId="1234">
<trade TrdId="Trade 1.1" col="0xCC9999" cmenu="YNYNYNYNYNYNYNY" AgreementId="1234">
</trade>
<trade TrdId="Trade 1.2"col="0xCC9999" cmenu="YYYYYYYYNYNYYYY" AgreementId="1234">
</trade>
</trade>
And adding columns which read this data like
advancedDataGridColumn.dataField="#TrdId"
so on...
protected override function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void{
var XMLdata:XML=rowNumberToData(dataIndex) as XML;
if(XMLdata!=null){
if(XMLdata.attribute(Constants.col) != undefined && XMLdata.attribute(Constants.col) != ""){
color=XMLdata.attribute(Constants.col);
}else{
color=0xFFFFFF;
}
}
super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);
}
this is best method to get data out of grid and do some processing...

Resources