on 06-30-2007 10:57 AM
Hi Gurus,
I want assign text dynamically to the lable but it's giving run time error lable for property not set of the lable.
Please provide me the sample cod
Regards,
Rahul.
Thanks a lot nithya your inputs really helped a lot..!
Reagards,
Rahul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
As nithya pointed out , you should dynamically set the label text.An one import thing is that ..You should set the label for field.Else it will throw error.
Thanks
Anzy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rahul,
Have a context attribute 'TEXT' of string/char type that will hold the value of the label text. Bind this attribute to the text property of your label element. In the context itself, give a default value for the attribute, so that it will be set initially. Then, whenever you want to change the label text, write the following code in the event handler:
method onactionchange_label.
data: label_text type string,
lr_element type ref to if_wd_context_element.
label_text = 'New text'.
lr_element = wd_context->get_element( ).
lr_element->set_attribute(
exporting
name = 'TEXT'
value = label_text
).
end method.
You will get the error while compiling if the text property is left blank. If it is bound to the context, you will not get the error. For the above code, the context attribute TEXT is not under any node. It is directly defined in the context. If you have your attribute in a node, change accordingly using the code wizard.
Hope this helps. <b>Please award points if it solved your problem.</b>
Regards
Nithya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rahul,
If I understand you correctly, you will be creating the label element itself dynamically and not the label text alone.
If you want to create the label element, in your <b>wddomodifyview</b> method, do the following:
data: lr_label type ref to cl_wd_label,
lr_trans_container type ref to cl_wd_transparent_container.
lr_trans_container ?= view->get_root_element( ).
lr_label = cl_wd_label=>new_label( text = 'your text' ).
lr_trans_container->add_child( lr_label ).
The method get_root_element will return you a reference to the rootuielement container, if you want to place your label directly under the root. Else if you need it in a group or any other container, you need to get that reference and add child.
Like this, you can create any number of labels you want. In every label, there is a property "label_for". Set this to the input field IDs for which the labels have been created. Check the class cl_wd_label for the method to set this property.
Hope this satisfies your requirement. If you want anything else, please explain in a bit more detail.
Regards
Nithya
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.