In Alloy Titanium, I can access XML elements with their id $.element_id but what if the element_id is a variable in the controller how i can get it.
for example, what i want to do is something like this :
var x = 'y';
$.x.open();
where x is an id for element in the view.
In such case you simply have to reference the view in a different way.
there you go:
var x = 'y';
$[x].open();
Let me know when this works-out for you.
Related
In Transaction BSP_WD_CMPWB I found a view from the WebUI Client.
I want to write a method that gets all the values of the attributes of the view structure.
How do I do this?
I think I need to find out somehow which BOL-Object this view structure belongs to...but I don't really know.
I started out like this...but no idea if I'm on the right track there :D
DATA:
ls_view TYPE "How do I find out the structure type name of my view, does it even exist?
lv_query_name TYPE CRM_OBJEXT_NAME VALUE. "How do I find out the query name I need to pass to get my view structure?
lr_query = cl_crm_iu_order_agent=>create_order_item_query_int( lv_query_name ).
ls_parameter-name = 'BUPA_NUMBER'. "This is an example filter for my specific case
ls_parameter-value = iv_partner.
APPEND ls_parameter TO lt_paramater.
lr_query->set_query_parameters( it_parameters = lt_paramater ).
lr_result = lr_query->get_query_result( ).
CHECK lr_result IS BOUND.
lr_bol = lr_result->get_first( ).
lr_bol->get_properties( IMPORTING es_attributes = ls_view ).
I've been having issues with the dgrid selection mix-in with multi selects.
Using the selection property (for example)
var selected = Object.keys(datatable.selection)
it returns an array of row ids as expected. However the ORDER of those ids seems to be "arbitrary". It seems perhaps that the order of selecting has an affect.
In any event, in the datatable, I want the selected rows to be returned in order that they display in the list, and they do not.
I can get them in the proper order using dojo.query(".dgrid-selected", datatable.domNode), and use the HTML element to get the row data, but this seems like a hack.
I cannot find a proper method to do this on the SitePen docs. Anyone?
I don't think that there is a direct way to do that. The Object.keys(datatable.selection) returns the array of ids in the order in which the rows are selected. You can use some built-in functions of d-grid and JS to achieve this. Below are the steps:
Get the id by Object.keys.
var selected = Object.keys(datatable.selection)
Create a list of objects comprising of id and rowIndex of element
Code:
var dataList= [];
for(var i=0; i< selected.length; i++){
dataList.push({id: selected[i], index: datatable.row(selected[i]).element.rowIndex});
}
Sort the list using index as the attribute:
dataList.sort(function(a, b){ return a.index- b.index; })
The resulting dataList would have the list of objects in order in which they appear in the grid.
I have a scenario where I'd like to N instances of a view to the TransparentContainer on a view with each receiving different parameters. To accomplish this I wrote some logic to dynamically create a cl_wd_view_container_uielement, add it to the cl_wd_uielement_container (the TransparentContainer on the main view) and then fire a plug using dynamic navigation to send my parameters. The code can be found below.
This all works with one problem: the created instances are not unique so I basically add N copies of the same view. N plugs are fired and handled but the last one sets the parameters for all views as there's just one instance. The view's WDDOMODIFYVIEW is also only fired once.
The code below was repurposed and cleaned up from a working version so I know it's possible. The big difference is that I'm adding a view from the same WDC in my scenario. In the original application the dynamically added view has its own Web Dynpro component and the caller also provides a dynamically created component usage.
Is there some way of creating multiple instances that I'm missing? Should I provide a component usage after all in this case? I've been tinkering with this for a few hours now but am not making any progress so I'd welcome any input to get me on the right track.
Code from the main view:
DATA:
lo_container TYPE REF TO cl_wd_uielement_container,
lo_subview TYPE REF TO cl_wd_view_container_uielement,
lo_flow_data TYPE REF TO cl_wd_flow_data,
lo_view_controller TYPE REF TO if_wd_view_controller,
lo_component_usage TYPE REF TO if_wd_component_usage,
lo_wdr_view TYPE REF TO cl_wdr_view,
lo_component_api TYPE REF TO if_wd_component,
lt_posts TYPE ztt_fi_vernot_posts,
ls_post LIKE LINE OF lt_posts,
lt_parameters TYPE wdr_event_parameter_list,
ls_parameter TYPE wdr_event_parameter,
lv_view_id TYPE string,
lv_source_plug_name TYPE string,
lv_target_embed_pos TYPE string,
lv_param_value TYPE REF TO DATA.
FIELD-SYMBOLS:
<lv_param_value> TYPE bu_partner
.
lt_posts = wd_this->mo_model->get_posts( iv_open = abap_true ).
" Retrieve and refresh the view container.
lo_wdr_view ?= wd_this->wd_get_api( ).
lo_container ?= lo_wdr_view->root_element.
lo_container ?= lo_wdr_view->get_element( 'TC_POSTS' ).
lo_container->remove_all_children( ).
LOOP AT lt_posts INTO ls_post.
" View and plug IDs should be unique.
CONCATENATE 'POSTS_' ls_post-index INTO lv_view_id.
CONCATENATE 'OUTPLUG_' ls_post-index INTO lv_source_plug_name.
" Create a new view.
lo_subview = cl_wd_view_container_uielement=>new_view_container_uielement( id = lv_view_id ).
lo_flow_data = cl_wd_flow_data=>new_flow_data( element = lo_subview ).
lo_subview->set_layout_data( lo_flow_data ).
lo_subview->set_layout_data( cl_wd_flow_data=>new_flow_data( element = lo_subview ) ).
lo_container->add_child( lo_subview ).
lo_view_controller = wd_this->wd_get_api( ).
CONCATENATE 'V_MAIN/' lv_view_id INTO lv_target_embed_pos.
* This was present in the source, returning a component usage via create_comp_usage_of_same_type()
* lo_component_usage = wd_comp_controller->get_component( iv_compcnt = ls_post-index ).
lo_view_controller->prepare_dynamic_navigation(
source_window_name = 'W_MAIN'
" Found in the window structure for this View
source_vusage_name = 'V_MAIN_USAGE_0'
source_plug_name = lv_source_plug_name
" target_component_name = '[WDC name]' " Optional?
" target_component_usage = lo_component_usage->name " Optional?
target_view_name = 'V_POSTS'
target_plug_name = 'SET_PARAMS'
target_embedding_position = lv_target_embed_pos ).
" Fill the paramaters. Note that the values should be passed as pointers.
REFRESH lt_parameters.
CLEAR ls_parameter.
ls_parameter-name = zcl_fi_vernot=>gcs_plugs-params-bp.
CREATE DATA lv_param_value LIKE ls_post-bp.
ASSIGN lv_param_value->* TO <lv_param_value>.
<lv_param_value> = ls_post-bp.
ls_parameter-value = lv_param_value.
INSERT ls_parameter INTO TABLE lt_parameters.
" Do the same for the contract.
CLEAR ls_parameter.
ls_parameter-name = zcl_fi_vernot=>gcs_plugs-params-contract.
CREATE DATA lv_param_value LIKE ls_post-contract.
ASSIGN lv_param_value->* TO <lv_param_value>.
<lv_param_value> = ls_post-contract.
ls_parameter-value = lv_param_value.
INSERT ls_parameter INTO TABLE lt_parameters.
" Finally, fire the plug.
wd_this->wd_get_api( )->fire_plug( plug_name = lv_source_plug_name parameters = lt_parameters ).
ENDLOOP.
This problem is not limited to dynamic generation of views but also occurs when you want to use a particular view more than once in a window of the same component. Only one instance is created so reuse is very limited.
The only solution to this would be to separate the the View off to its own Web Dynpro component or to create multiple component usages of the active WDC and using those in dynamic navigation.
I've been digging around a little trying to figure out how I should locate the "tweet_id" in my #savedtweets table and then locate that same "tweet_id" in my #newtweets table from a controller, so far I'ved tried something like this;
CONTROLLER
#stweet = Savedtweet.find(params[:id])
#newtweet = Newtweet.where(:tweet_id => #stweet.tweet_id)
#newtweet.status = 'new'
#newtweet.save
Basically I need to change the string "saved" in my Newtweets table to "new" based on the current Savedtweet ID. I just can't figure it out. If I do the following in console;
#stweet = Savedtweet.first
#newtweet = Newtweet.where(:tweet_id => #stweet.tweet_id)
It finds the right one. I've got to be close just not there yet. :)
You could do:
Newtweet.find_by_tweet_id(#stweet.tweet_id).update_attribute(:status, 'new')
The reason your code isn't working is because Newtweet.where() returns an array of objects. It should be Newtweet.where().first, though Newtweet.find_by_tweet_id is the preferred method.
Can you create a custom User Story grid in Rally with the following query?
(((Parent = null) AND (Owner.Name = "dummy.name#email.com")) OR ((Parent.Name contains "Example") AND (Owner.Name = "dummy.name#email.com")))
Every time I try to do this it only returns results for the second part of the query. It seems like it cannot combine the Parent = null and the Parent.Name contains "Example".
Thanks for any feedback! I know that we could create two grids, but it would be nice to combine it into one.
This looks like a bug to me. Ignoring the owner portion of the query and taking just the Parent portions, per the title of your question: ((Parent = null) or (Parent.Name = 'xxxx')), it seems that I am also always seeing results that match the latter condition. If I switch the order, I get Parent-less stories. I'd recommend submitting a Case to Rally Support - rallysupport#rallydev.com - they can get this filed with the Rally developers.