This discussion is archived
10 Replies Latest reply: Dec 26, 2012 2:34 AM by 884536 RSS

On select delete rows

571912 Newbie
Currently Being Moderated
Hi , I have a custom page with Add Row button. On click of button it adds new rows.
Now new requirement has come ,to add new button delete rows. For this a check box should be added against each row and on select of check box and delete the row should be deleted.

How to capture the selected row? The above said is all new requirement.How to proceed on this ? pl help me on this requirement.

Thanks,
Ragahv
  • 1. Re: On select delete rows
    Shrikant A Explorer
    Currently Being Moderated
    hi,
    I hope you are using adv. Table for this. If so, than please add Selectflag column in vo. and Used multiple selection in the Adv Table. When user select the chech Box, at that time "Y" is set to selectFlag. your task is just check the selectFlag for "Y".

    --
    Thanks,
    Shrikant
  • 2. Re: On select delete rows
    571912 Newbie
    Currently Being Moderated
    Hi
    There is no adv table used for this.Table and flowlayout are being used .If this is the case how to implement the adv table region or any other way to do
  • 3. Re: On select delete rows
    Sushant Sharma Expert
    Currently Being Moderated
    Hi,

    In your table region, create a new item of type check box.
    In the VO used for table region, create a new transient attribute and map that to the above created check box.

    Now, while deleting, you can check whether the check box is selected or not (by getting the value of transient attribute) and delete only those rows.

    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
  • 4. Re: On select delete rows
    Shrikant A Explorer
    Currently Being Moderated
    Hi,
    I suggest you should used Adv. Table for this, Because If you are using Table than, you have to follow the steps suggested by Sushant and have to create fire action on the checkbox and also update your VO for some value.

    --
    Thanks,
    Shrikant
  • 5. Re: On select delete rows
    571912 Newbie
    Currently Being Moderated
    Hi Sushant,
    As per your suggestion, i have done the changes on the PG.
    On click of DelRow button , i am calling an firePartialAction event. Now how to capture the selected Y flag values and delete.
    can you pl post some psuedo code if any
  • 6. Re: On select delete rows
    Sushant Sharma Expert
    Currently Being Moderated
    Hi,

    Now get all the rows in an row[] array and for each check whether that transient attribute is 'Y' or not.
    If it is selected, then remove that row. Below is sample code for the same:

    deleteMethod() {
    XxVOImplvo = getXxVO1();
    Row row[] = vo.getAllRowsInRange();
    For (int i =0; i<row.length;i++) {
    XxVORowImplrowi = (XxVORowImpl) row;
    if ("Y".rowi.getTransAtt().toString()) {
    rowi.remove();
    getOADBTransaction.commit();
    return;
    }
    }
    }

    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  • 7. Re: On select delete rows -- URGENT
    571912 Newbie
    Currently Being Moderated
    Hi Sushant,
    I have implemented the changes as suggested and problem i faced is on select of check box the value is coming as "on" but not as "Y".
    So i have chaged in the page,set checked value to "Y" for the check box.

    On click of Del Row button the row is removed from the page. But when i click on final Save button the removed rows are coming back on the page. Below is my code.

    public void delFinalRespRow()
    {
    OADBTransaction oadbtransaction = getOADBTransaction();
    FinalRespVOImpl finalrespvoimpl = getFinalRespVO();
    Row arow[] = finalrespvoimpl.getAllRowsInRange();
    for(int i = 0; i<arow.length;i++)
    {
    FinalRespVORowImpl finalrespvorowImpl = (FinalRespVORowImpl)arow;
    //if(finalrespvorowImpl.getSelect() != null && finalrespvorowImpl.getSelect().equalsIgnoreCase("Y"))
    if("Y".equalsIgnoreCase(finalrespvorowImpl.getSelect().toString()))
    {
    finalrespvorowImpl.remove();
    oadbtransaction.commit();
    return;

    }
    }

    }

    pl correct me if anything is wrong

    I need to close this issue ASAP. pl share some info. why are the rows not deleted permanently. They are just hidden on the page, but when we come back the rows are seen.
  • 8. Re: On select delete rows -- URGENT
    Shrikant A Explorer
    Currently Being Moderated
    Hi,
    I think you are removing the row from VO/Table only(Not from DB). And refreshing the page After Save button is click. Thus, VO executes and DB values comes again on the page.

    --
    Thanks,
    Shrikant
  • 9. Re: On select delete rows -- URGENT
    Ahmed_Sayeed Newbie
    Currently Being Moderated
    Clear the cache of your VO and then do execute VO again.
  • 10. Re: On select delete rows -- URGENT
    884536 Newbie
    Currently Being Moderated
    Hi,
    add a commit stmt after deleting a row.

    OADBTransaction tr = getOADBTransaction();
    tr.commit();

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points