Crosstab callback function

(7 posts) (2 voices)
  1. ajdjackson, Member

    Hi

    Going round the bend with this.

    I've been able to do this before but I can't get it to work now.

    I've a simple crosstab report in which I've set up editing of a value an I wish to get the hsum to update on change.

    This is where I've gotten to:

    select 'dbr.javascript', 'function mycallback() {

    // Calculate sum of edited column autosum_int(this);

    ct_total( $(this).parent().children()[3] );

    }';

    select 'dbr.title',concat("Sales Data Input Module for ",(select CustName from customer where `Customer Code` = inCustID)," for ",inYear);

    select 'dbr.embed_object','createx';

    select 'dbr.report', 'sp_DBR_Bud_Add_Existing','createx','inCust=1','inYr=2'; select 'dbr.button', 'Add Existing Product'; select vCust,vYear;

    select 'dbr.crosstab','Mon'; select 'dbr.crosstab.col','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'; select 'dbr.hsum', 'Qty'; select 'dbr.hidecolumns','Cust'; select 'dbr.colstyle','Qty','%0.0f;-;';

    select 'dbr.editable', 'Qty', 'sp_DBR_Budget_Qty', 'inCust=Cust','inProd=PCode', 'inYr=Year','inMon=Mon',"options={'onblur':'','callback':mycallback}";

    select c.`Item Code` as "Product Code[PCode]", c.`Item Description` as "Product[Prod]", date_format(a.budDate,"%b") as "Month[Mon]", ifnull(a.budQty,0) as "Qty[Qty]", inCustID as "[Cust]", inYear as "[Year]" from tblbudgets a join `item master` c on a.budProdID = c.`Item Code` where a.budCustID = inCustID and year(a.budDate) = inYear;

    I'm obviously not understanding this at all.

    Cheers

    Jake

  2. myDBR Team, Key Master

    Just set the callback to autosum_int (or autosum_float); no need for custom callback. myDBR will automatically refresh both the horizontal and vertical sums.

    --
    myDBR Team

  3. ajdjackson, Member

    Hi

    Thanks for getting back.

    Found out what was stopping my effort working:

    select 'dbr.colstyle','Qty','%0.0f;-;';

    Once I commented this out my js function worked. :)

    Cheers

    Jake

  4. myDBR Team, Key Master

    We'll change the calculation that it will allow '-' as a style.

    You still do not need the custom callback. You are essentially doing the calculation twice. To keep is short, you can use:

    select 'dbr.editable', 'Qty', 'sp_DBR_Budget_Qty', 'inCust=Cust','inProd=PCode', 'inYr=Year','inMon=Mon',"options={'onblur':'','callback': autosum_int}";

    If you really want to create your own custom callback, the first parameter for the ct_total can be JavaScript 'this' as it will point to the edited column. The $(this).parent().children()[3] will be just the Jan column (no need for this).

    --
    myDBR Team

  5. ajdjackson, Member

    Thanks that would be great. The '-' looks a lot better than a table full of zeroes.

    After a couple of hours of going round in circles the penny dropped as to what was wrong.

    Cheers

    Jake

  6. myDBR Team, Key Master

    Jake,
    you can also use style:

    select 'dbr.colstyle','Qty','%0.0f; ;';

    , which while hide the zeros and let's user concentrate on cells that do have non-zero values.

    The newest build will allow for you to use the '-' style as well.

    --
    myDBR Team

  7. ajdjackson, Member

    Cheers worked a treat!

    Jake


Reply

You must log in to post.