cancel
Showing results for 
Search instead for 
Did you mean: 

Button in a table row to get value of a column.

Former Member
0 Kudos

Hello,

I am following [this thread|] to get the value of a column up on button click (the button is in the same row).

Here is the code in wdDoModify ()


if (firstTime)
	  {
		IWDButton button = (IWDButton) view.getElement("TableCellEditor");
		button.mappingOfOnAction().addSourceMapping("ScheduledCourses", "row");
	  }

Here is the code in the button action()


 public void onActionRegisterStudent(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.gfc.hr.training.wdp.IPrivateCourseRegistrationCompView.IScheduledCoursesElement row )
  {
    //@@begin onActionRegisterStudent(ServerEvent)
	wdContext.nodeScheduledCourses().setLeadSelection(row.index());
    //@@end
  }

The context node for the table is "ScheduledCourses"

When I click the button, I get an exception....


com.sap.tc.webdynpro.services.exceptions.WDIllegalArgumentException: Parameter ScheduledCourses not found 

Accepted Solutions (1)

Accepted Solutions (1)

shabeer_skhan
Explorer
0 Kudos

Hi Srinivas,

Assuming you have a node 'ScheduledCourses' with two attributes 'courseId' and 'courseName' and you want to display the 'courseName' on click of the button placed in a particular row of the table, please try the following (Most of them you have already done, if i am not wrong. I am listing the entire steps so that you can check whether you have missed any thing).

1. Place a Table UI element and bind the datatsource property to the node 'ScheduledCourses'

2. Insert a new column in the table and for the column insert a table cell editor and select 'Button' from the list.

3. select the button(table cell editor) and create an action for the button. While creating an action create a parameter with name 'courseElement' and type as IPrivate<ViewName>.IScheduledCoursesElement (Interface representing element of ScheduledCourses node)

3. In wdDoModifyView() write the following code


    if(firstTime){
    	
    	IWDButton button=(IWDButton)view.getElement("Button1");
    	button.mappingOfOnAction().addSourceMapping("nodeElement","courseElement");
    	
    }

Here "Button1" is the id of the button inserted in the table column. The string "nodeElement" should be written as such and "courseElement" is the name of the parameter which we have created for the action of the button.

4. Now in the action created for the button try to print the courseName as shown


 wdComponentAPI.getMessageManager().reportSuccess(courseElement.getCourseName());

Regards,

Shabeer

Answers (1)

Answers (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Srinivas,

Some modifications are required in your code. The action method is perfectly fine.

Just modify the wdDomofiy method. In the addSourceMapping, you need to pass the nodeElement as the parameter. This is predefined and you cannot change it to anything else. In your case you have used a different name.:


if (firstTime)
 {
	IWDButton button = (IWDButton) view.getElement("TableCellEditor");
	button.mappingOfOnAction().addSourceMapping("nodeElement", "row");
}

Just try this code and I am sure this will work. Please revert back in case you have any further issues in this.

Thanks and Regards,

Pravesh