3.0.5

runtime computations

I have this work in progress app -- http://23ve4.com/h1.htm

I need help with figuring out how to add a button that will compute percentages. I just do not know enough to do this myself ...

when the display occurs, 18 lines of data appear. I would like for a button to exist that, when clicked, that page is redisplayed with percentages shown in the last 3 columns where the percentage is computed as the value in line k as a percent of the value in line 1 (but the value shown in line 1 remains the existing value and not 100.00).

The Show All and Find buttons work.
The state button and geotype buttons do not yet work; I will fix this.

Thank you for any possible help with this.


Warren
November 21,
How are you going to handle sorting in this case?
Alex (ActiveWidgets)
November 24,
Thank you. Assume there would be not sorting (when the percent button is clicked but yet otherwise enabled as normal). While sorting would be preferred, the main objective is to show the the 17 lines (sometimes it might be 16 lines) as percentages of the first line/row. also, I will generalize this a bit to handle more than 3 columns of numbers, always the rightmost N columns.

Thank you for any possible help.
Warren
November 27,
rRelated to this, I have browsed over the many postings regarding printing a simple grid and come away with no workable solution. Is there a straightforward way to print the grid at hand?

Thank you.
Warren
November 27,
Maybe something like this -

...

obj.setCellModel(table);

function pct(col, row){

    var base = this.getCellValue(col, 0);
    var value = this.getCellValue(col, row);

    if (row == 0){
        return this.getCellData(col, 0);
    }
    else {
        return (100*value/base).toFixed(2) + '%';
    }
}

obj.setCellText(pct, 5);
obj.setCellText(pct, 6);
obj.setCellText(pct, 7);

...
Alex (ActiveWidgets)
November 27,
Thank you. getting closer ...

I put the suggested code in (http://23ve4.com/h1.htm) but cannot get three sample obj.setCellText statements positioned correctly, so no computation made. can you suggest how to make this work?

Thank you.
Warren
November 30,
Hi Warren,
I am trying your sample to find a solution to other issue I encountered, but getting an "sintax error" in the first line of the csv file on the error-console in FF 3.53 when running it locally.

@ Alex, what could cause this?
IsnĀ“t the csv correct?
empty nodes?

Thanks
Carlos
November 30,
Carlos,

Thank you.

Running FF 3.5.5 I do not encounter a syntax error ... okay w/IE 8 too. The first data line/row is that as shown when the grid populates and has no null values.

I know the obj.setCellText statements are positioned incorrectly but do not know how to correct.
Warren
November 30,
Try to put them all before document.write(obj)
but change if (row ==0){ .. with.. if (row <5){
November 30,
Also, the combos are pointing to incorrect columns numbers right?
i mean the filter functions
Carlos
November 30,
I did move the obj.setCellText statements to before document.write(obj) .. but this does not work ... it needs to be conditional upon when the buttonpct is clicked ( then a refresh w/o percents is needed).

Re:
but change if (row ==0){ .. with.. if (row <5){
I tried this and it seems to have no role; rows 0-4 are just not computed in this case.

I appreciate your help ... need something else/more.

Thank you.
Warren
November 30,
Thank you.

the filter functions all work correctly.

everything is okay except with respect to the addition of the buttonpct and related function (just last few lines in the script).
Warren
November 30,
Warren
If the base number ( total column summ) remains always the same ( regardless it's filtered or not) I would suggest to create some dummy-empty columns and show/hide ( the dummy/real) on this button click.
If not you need to calculate the total on each filter process ( not sure how ).
HTH
Carlos
December 1,
Hoping someone can take one more look at this ... The obj.setCellText statements need to be conditional (on click buttonpct) - where? and there needs to be a reset button - how to refresh grid? (Show All button does not operate after buttonpct clicked)

all relevant code is right at end of script (from obj.setCellModel(table);
statement down) -- http://23ve4.com/h1.htm

Thank you.
Warren
December 1,
Carlos,

Thank you. The base number is always row 1/top row but may (typically) change; e.g. if the filter is applied an state=AZ then the top row is AZ total etc. I remain stuck.
Warren
December 1,

This topic is archived.

See also:


Back to support forum