cancel
Showing results for 
Search instead for 
Did you mean: 

reading selected rows from table

Former Member
0 Kudos

Hi, I have table with one clomn, which displays EmployeeId's. User can select multiple rows for processing , how do i read the rows that user selected.

In short how do i read the list of Employees selected.

Regards,

Venki

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Lets say your node name is "Employees", from this if you want to know the selected one use the following code.


int elements = wdContext.nodeEmployees().size();
	  for(int x=0; x<elements; x++)
	  {
		  if(wdContext.nodeEmployees().isMultiSelected(x) == true)
		  {
			  IEmployeesElement empElement = wdContext.nodeEmployees().getEmployeesElementAt(x);
			  // TODO rest of the processing
		  }
	  }

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

I think your question should be solved at this moment. Codes above should work. One small detail I'd point out, I'm quite new in SDN Forums but I keep seeing this kinda of code.


if(wdContext.nodeEmployees().isMultiSelected(x) == true)

Coding IF's when you're checking boolean, avoid using "== true" - Just use the variable as the clause of IF. And case you really wanna use that, do it like "true == condition" - You can do a typo and use just "condition = true" - It will compile and give you some trouble later.

String is another common case, "if (nodes....equals("X"))" - Do it like "X".equals(....) - This way you will be sure this will never evaluate a Null Pointer Exception, even if there are some additional changes.

These small things usually make code clearer and cleaner. And they are also considered best practices when it comes do programming.

Regards,

Daniel

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Expert

1) Set the propert "selectionMode" of the table to "Multi".

2) Then use this code:

public List getEmployeeID() {

List empIDList = null;

int lead=wdContext.nodeEmployeeTable().getLeadSelection();

int size = wdContext.nodeEmployeeTable().size();

for (int i = 0; i < size; i++) {

IEmployeeTableElement elem = wdContext.nodeEmployeeTable().getEmployeeTableElementAt(i);

if ((wdContext.nodeEmployeeTable().isMultiSelected(i)) || lead==i ) {

empIDList.add(elem.getEmployeeID());

}

}

return empIDList;

}

thanks

sudhira

pravesh_verma
Active Contributor
0 Kudos

Hi Venki,

Use the following code:



int selectedRow = wdContext.node<Node_Name>().getLeadSelection();

This will give you teh leadSelected row.

But in case you have multiple rows then you have to use the propert of multiSelect. Follow these steps:

1) Set the propert "selectionMode" of the table to "Multi".

2) Then use this code:


public List<String> getEmployeeID() {
			List<String> empIDList = null;
			
			int size = wdContext.nodeEmployeeTable().size();
			for (int i = 0; i < size; i++) {
				IEmployeeTableElement elem = wdContext.nodeEmployeeTable().getEmployeeTableElementAt(i);
				if ((wdContext.nodeEmployeeTable().isMultiSelected(i))) {
					empIDList.add(elem.getEmployeeID());
				}
			}
			return empIDList;
		  }

I hope this helps

Thanks and Regards

Pravesh

Edited by: Pravesh Verma on Mar 23, 2009 3:54 AM