cancel
Showing results for 
Search instead for 
Did you mean: 

Table rows changed by user or not

former_member188556
Active Contributor
0 Kudos

I have a table with 5 rows.

Each row has an input field.

On page load the table will be populated with these inputs fields with saved data from the backend.

It will be editable for the user.

There is a save button per row so that user can save the changes per each row.

Now I want to display on action of a button all the changed and unsaved rows in this table.

I tried with isChangedByClient() method, and it returns true. But how will i reset for this for a particular row after save on that row?

Regards

BP

Accepted Solutions (1)

Accepted Solutions (1)

Anmol_Kumar
Participant
0 Kudos

Hi BP,

Can you please explain in details "how will i reset for this for a particular row after save on that row" ?

former_member188556
Active Contributor
0 Kudos

Anmol,

If the user edits any input field on any row isChangedByClient will become true for that row.

Quite good. But even after the user saving the row, the method, isChangedByClient is still true.

Regards

BP

former_member197348
Active Contributor
0 Kudos

Hi BP,

Did you try

wdContext.resetChangedByClient()

after save?

Regards,

Siva

former_member188556
Active Contributor
0 Kudos

Yeah,

I tried that, but after that, for all the rows of the table, isChangedByClient is false.

Regards

BP

pravesh_verma
Active Contributor
0 Kudos

Hi BP,

This is quite tricky one. Try this approach.

Do the source mapping in wdDoModifyView as below to the button UI element you created in column.


IWDButton button = (IWDButton) view.getElement("Your_Button_ID");
button.mappingOfOnAction().addSourceMapping("nodeElement", "element");

Then in the action of the button add that node element as arguement with arguement name as "element" (this is must - because we did the source mapping with the name "element" ) as below. We will get the index of the row which is changed or not using this nodeElement.

Now create a global parameter in the Begin Other and End. it is at the bottomof the code.


List<IWDNodeElement> changedList = new ArrayList<IWDNodeElement>();

This list will contain the changed element of the table.

Now in the action of Button, you can get the reference of all those elements which has been changed and which has not been changed. use the following code


public void onActionSave (com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, IPrivateTestView.ITestValuesNodeElement element )
  {
    //@@begin onActionSave(ServerEvent)

// NOTE: this function will be called only when you will hit the button in the column that means you have changed the value in the input field.
IWDNodeElement nodeEle = wdContext.node<Your_Node_Name>().getElementAt(ele.index());

// You have defined this changedList as the global parameter. All the changed element will be added to this list.
if(!changedList.contains(nodeEle)){
	  changedList.add(nodeEle);
}    
//@@end
}

I hope this solves the issue. Please revert back in case youhave any further issues.

Thanks and Regards,

Pravesh

Regards,

Charan

Answers (0)