how to retrieve a column's values in order to update a column total - ag-grid

I have a pinned row that acts as a column's total, which works fine using gridOptions.pinnedBottomRowData. I need to update this value when the columns' cells' values change but I cannot find a means of accessing the column values to do so. What's the best means of updating a column total when it's columns' cells' values change?

You can calculate the total on cell value changed or value setter function.
this.gridOptions.onCellValueChanged = function (event) {
if (event.colDef.colId == "ColumnName") {
//Logic to update the total row value
total = total + event.data[event.colDef.field]
}
}

Related

Tableau count number of Records that have the Max value for that field

I have a field where I'd like to count the number of instances the field has the max number for that given column. For example, if the max value for a given column is 20, I want to know how many 20's are in that column. I've tried the following formula but I have received a "Cannot mix aggregate and non-aggregate arguments with this function."
IF [Field1] = MAX([Field1])
THEN 1
ELSE 0
END
Try
IF ATTR([Field1]) = MAX(['Field1'])
THEN 1
ELSE 0
END
ATTR() is an aggreation which will allow you to compare aggregate and non aggregate values. As long as the value you are aggregating with ATTR() contains unique values then this won't have an impact on your data.

How to assign the same value to all table cells in a column in a table in Matlab?

I tried
myTable.MyField{:}='AAA'
myTable.MyField(:)='AAA'
myTable.MyField{:}={'AAA'}
myTable.MyField{:}=deal('AAA')
but all failed.
Is there any way?
MATLAB requires:
To assign to or create a variable in a table, the number of rows must match the height of the table.
So it would be:
myTable.MyField = repmat('AAA', length(myTable.MyField), 1);
or if you know the column number of MyField, you can do:
myTable(:,colnum) = {'AAA'}; %where colnum is the column number
or otherwise if you don't know the column number, you can directly use the column name as well:
myTable(:,'MyField') = {'AAA'};

how to access one by on value of the stored procedure and calculate the average of them row wise

I executed a stored procedure in java which results into a table of 16 column and 3600 rows.Now I want to access 3 column of the retrieved table in row by row fashion and calculate the average of all column in row wise fashion.To do this,I need to access values of columns one by one .How to do it. My code for accessing column is
while (rs.next())
{
a1=rs.getDouble(7);
a2=rs.getDouble(8);
a3=rs.getDouble(10);
sum +=(a1+a2+a3);
}
return sum/3;
but through this,i think i'am getting a total average of all the columns .But i need average of column row by row i.e average of all three column of first row,then second row ...like this.
You are indeed adding all the values from 3 columns and doing row by row addition.
If you want row by row, then for each entry that you get from database you need to store the result in a list like below and return it where needed:
List<Double> averageList = new ArrayList<Double>();
while (rs.next())
{
a1=rs.getDouble(7);
a2=rs.getDouble(8);
a3=rs.getDouble(10);
averageList.add((a1+a2+a3)/3.0);
}
return averageList;

delete rows based on checkbox selection in slickgrid

i am taking help of this example: http://mleibman.github.com/SlickGrid/examples/example-checkbox-row-select.html and add a checkbox column to my grid and assign unique_id value of my record to the id of checkbox column i am getting checked columns number using grid.getSelectedRows();
it gives me a index number of row. how can i get id of this selected rows in slickgrid? please help me if anyone have any idea.
var selectedrows = grid.getSelectedRows();
for(i=0;i<len;i++){
var d = grid.getData().getItem(selectedrows[i]);
if(d != null && d != 'undefined'){
dataView.deleteItem(d.id);
grid.invalidate();
grid.updateRowCount();
grid.render();
}
}
It removes rows from grid. not from server side.

Cassandra: Update multiple rows?

In mysql, I can do the following query, UPDATE mytable SET price = '100' WHERE manufacturer='22'
Can this be done with cassandra?
Thanks!
For that you will need to maintain your own index in a separate column family (you need a way to find all products (product ids) that are manufactured by a certatin manufacturer. When you have all the product ids doing a batch mutation is simple).
E.g
ManufacturerToProducts = { // this is a ColumnFamily
'22': { // this is the key to this Row inside the CF
// now we have an infinite # of columns in this row
'prod_1': "prod_1", //for simplicity I'm only showing the value (but in reality the values in the map are the entire Column.)
'prod_1911' : null
}, // end row
'23': { // this is the key to another row in the CF
// now we have another infinite # of columns in this row
'prod_1492': null,
},
}
(disclaimer: thanks Arin for the annotation used above)