Skip to Content
author's profile photo Former Member
Former Member

how to Fetch multiple rows from table View using PDK

hi,

i have an requirement in which the user has to select multiple rows in a table.

upon firing event those particular rows should get deleted from the database.

i am coding in PDK.

i have used tableview to display those rows.

i am facing a problem while trying to get those selected rows.

if anyone has ever worked on such a scenario, please help me. sample code would be helpful.

thanks & regards,

mrudula

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 09, 2007 at 01:34 PM

    Hello,

    I'll check asap. in between, could you give the error you got ?

    Your coe seems a little stange to me : you're filling the vector v_data even when the line is not selected, with possible duplicate or null values :

    the code

    Vector v_data = new Vector();
    int i;
    for(i=firstVisibleRow;i<lastVisibleRow;i++){
    if(tableView.isRowSelected(i)){
    temp[0] = tableView.getValueAt(i,0).getValueAsString();
    temp[1] = tableView.getValueAt(i,1).getValueAsString();
    temp[2] = tableView.getValueAt(i,2).getValueAsString();
    }
    v_data.add(temp);
    }

    should , in my opinion, be something like the following

    Vector v_data = new Vector();
    int i;
    for(i=firstVisibleRow;i<lastVisibleRow;i++){
    if(tableView.isRowSelected(i)){
    temp[0] = tableView.getValueAt(i,0).getValueAsString();
    temp[1] = tableView.getValueAt(i,1).getValueAsString();
    temp[2] = tableView.getValueAt(i,2).getValueAsString();
    v_data.add(temp);
    }
    }
    

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi,

      sorry for the delay in reply.

      my problem is solved, when i went thru other posts.

      i should actually get the value from the Bean. like i gave below.

      temp[j]=myBean.getPoViewModel().getValueAt(i,1).getValueAsString();

      thanks anyways. i am awarding points as useful answer.

      Regards,

      mrudula

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2007 at 12:26 PM

    Hello,

    there is several way you can do this

    1/ standard

    as i remember, you may set the tableview to multi-line selection. this will allow the user to select more than one line. I think there is an event called at each selection / deselection. You get the index, and either add it or remove it from the selected' collection. (this is a bit theoretical, since i've not used this method for a long time)

    2/ specific.

    you put an event on a given column. the representation of this column should depend on the selected/not selected value. at each click, you get an event, and set/unset the selected attribute. you may then iterate on the collection for the objets with the selected attribute set

    hope this helps

    Guillaume

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Guillaume,

      Thanks for your Reply.

      I have used the following code:

      TableView tableView=(TableView)this.getComponentByName("tv_po");

      int firstVisibleRow= tableView.getVisibleFirstRow();

      int lastVisibleRow= tableView.getVisibleLastRow();

      String temp[] = new String[ tableView.getColumnCount()];

      Vector v_data = new Vector();

      int i;

      for(i=firstVisibleRow;i<lastVisibleRow;i++){

      if(tableView.isRowSelected(i)){

      temp[0] = tableView.getValueAt(i,0).getValueAsString();

      temp[1] = tableView.getValueAt(i,1).getValueAsString();

      temp[2] = tableView.getValueAt(i,2).getValueAsString();

      }

      v_data.add(temp);

      }

      this is giving me an error.

      if i am using the following code for if loop, then i am able to print the index of the selected row.

      if(tableView.isRowSelected(i)){

      break;

      }

      myBean.setIndex(i);

      so, i want to know whether there is any other way of retrieving the value of the particular cell.

      can u please help.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.