cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the particular cell value ?

Former Member
0 Kudos

Hi All,

I have created a dynamic table which fetches data from R/3.

My requirement is to change the particular cell value .

Ex:

Desc

A

B

I want to replace this A value with C value.

How to access this particular cell value?

Pls note that everything is dynamic.

pls suggest.

Regards,

Subashini.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ayyapparaj,

Thanks for your reply. I tried with your code. But its replacing only the entire column since I am destroying the table cell editor and passing link to action object. I have created a dynamic table which contains link to action for particular column. I have to replace the particular cell value with another value.

Ex:

String colVal = //getting value from the bapi

IWDAction act = wdThis.wdGetAction();

IWDLinkToAction action = (IWDLinkToAction)view.createElement(IWDLinkToAction.class,null);

action.setText(colVal);

action.setEnabled(true);

action.setOnAction(act);

action.setVisible(WDVisibility.VISIBLE);

column.destroyTableCellEditor();

column.setTableCellEditor(action);

Output:

A(link to action)

B(link to action)

Now I have to replace A value with C value.

Pls help me. Its very urgent.

Regards,

Subashini.

Former Member
0 Kudos

Hi Subhasini,

While creating link to action , give some uniqe id to it instead of null.

IWDLinkToAction action = (IWDLinkToAction)view.createElement(IWDLinkToAction.class,"Action" + i );

Here ' i ' is the count (integer).

this way you can access the particular element again as follows-

IWDLinkToAction action1 = (IWDLinkToAction)view.getElement("Action" + i );

Now set all the values in action1 as you want.

action1.setText(colVal);

.....

......

Now set the table cell editor to action1.

column.destroyTableCellEditor();

column.setTableCellEditor(action1);

Thanks and Regards

Deepak

Former Member
0 Kudos

This is wrong. You must bind the properties of cell editors to context attributes inside the table's data source node, otherwise you will get the same value for each row.

Armin

Former Member
0 Kudos

Hi Armin,

Thanks for your reply. Yeah, what you said is correct. I am getting the same value for each row.

if(fieldName.equalsIgnoreCase("Zzbus_Unit_D")){

IPrivateView.IbapiNode bapiNode = wdContext.nodebapiNode();

IWDLinkToAction action= null;

for(int index=0;index<wdContext.nodebapiNode().size();index++) {

IPrivateView.IbapiElement bapiElem = bapiNode.getbapiElementAt(index);

IWDAction act = wdThis.wdGetAction();

action = (IWDLinkToAction)view.createElement(IWDLinkToAction.class,null);

if(bapiElem.getZzbusuni_Fkkopru()== null || ( (bapiElem.getZzbusuni_Fkkopru().equalsIgnoreCase("") && bapiElem.getZzbusuni_Fkkopru().length() == 0))){

IPrivateView.IbapiElement hyphenElem = bapiNode.getbapiElementAt(index);

hyphenElem.setZzbus_Unit_D("-");

colVal = hyphenElem.getZzbus_Unit_D();

action.setText(colVal);

}

else{

colVal = bapiElem.getZzbus_Unit_D();

action.setText(colVal);

}

action.setEnabled(true);

action.setOnAction(act);

action.setVisible(WDVisibility.VISIBLE);

column.destroyTableCellEditor();

column.setTableCellEditor(action);

}

}

Where am I doing wrong?

Pls help me.

Regards,

Subashini.

Former Member
0 Kudos

First, ask yourself: Do I really need to recreate the view layout when data change or do I just have to update the context values to which the UI elements in my view layout are bound.

In this example, you could maybe use a Table instead of creating the LinkToAction elements programmatically?

In your code, it seems you should do something like


action.bindText("bapi.Zzbus_Unit_D");

Armin

Former Member
0 Kudos

He passes NULL as ID which is perfectly valid as this assign a unique ID automatically.

And setting the property value of a table cell editor has just the effect I described above.

Armin

Former Member
0 Kudos

Hi Armin,

Thanks for your reply. I can able to replace the particular cell value with "-". Since it is link to action column am getting hyperlink for that hyphen. But I dont want to display this hyphen as hyphen. How to remove link to action for this hyphen.

Please guide me.

Regards

Subashini

Former Member
0 Kudos

Bind the "enabled" attribute to a boolean attribute under the table data source and set this to "false" if the link should be disabled in a certain row.

Armin

Former Member
0 Kudos

Hi Armin,

I am setting hyphen for particular cell value by using the following code:

I am creating an element for the bapiNode and then setting hyphen value to it.

hyphenelement is an element for the bapiNode

hyphenelement.set<bapiattrname>("-");

String colVal = hyphenelement.get<bapiattrname>();

action.setText(colVal);

Based on some condition am setting this hyphen value.

Otherwise I will set the values from the bapi like the below:

action.bindText(bapiNode.attrname);

As you said, setText is giving same value for each row if I perform any click event.

Since I am using setText to set the hyphen ,I am getting hyphen in the entire column if I click any button on the same page.

Is there any other method to set the hyphen for the particular cell value?

Pls guide me.

Regards,

subashini.

Answers (2)

Answers (2)

Former Member
0 Kudos

hi,

suppose you have 2 rows and 3 columns(name, id, age) and you want to change the value of the age cell in the 2 nd row.....then you can use the following code


//looping witht the size of the node, that is the no. of rows
for(int i=0;i<wdContext.nodeEmpNode().size();i++)
{
	IEmpNodeElement element =
	wdContext.nodeEmpNode().getEmpNodeElementAt(i);
//getting the second row as per my snenario
	if(i=1)
{
//changign the value of the cell age int he 2nd row
 element.setAge(c);
}

}

regards,

pinki

Former Member
0 Kudos

Hi pinki,

Thanks for your reply. I am fetching the values from the R/3. So it is not allowing me to set the value for the specific attribute as you mentioned.

I am creating a table dynamically by binding the node from the R/3. I am not creating any context node separately.

Is there any other way to change the particular cell value?

Pls suggest.

Regards,

Subashini

Former Member
0 Kudos

Hi Subhasini,

I am not expert in dynamic programming but still you can try if you want. Instead of setting the text through code action.setText(colVal); try binding the text using action.bindText() code. You have to pass the attribute info of the attribute (Attribute A, i believe) of dynamically generated node as the parameter to bindText method. And then follow Ayyaparaj's or Pinki's code to set the data.

Regards,

Gopal

former_member201361
Active Contributor
0 Kudos

hi,

u might have created a action for the LinktoAction UI Element. while creating the Action u might have given the text for the Action.if yes then please remove the text value in the Action method as i had a similar problem of binding the text TableCellEditor.

when u want to set the value "C" to A , destory the LinkToAction Ui Element and

again create alink toAction Ui Element and Bind the text withe Value "C". finally bind the Action to the LinkToAction UI Element.

Thanks and regards

Fistae

Former Member
0 Kudos

Hi,

You have to access the element which shows this cell value and change it

Ex:

wdContext.node<YourNode>().setLeadSelection(<row which contains the cell>);

wdContext.current<Your Nodeelement>().setAttributeValue(attributename, value);

OR

I<Your Element> element = wdContext.node<YourNode>().get<Your>Element((<row which contains the cell>);

element.setAttributeValue(attributename, value);

Regards

Ayyapparaj