How do I select rows where 2 numbers are closest?
Hi,
I need to select one row from each person where the days are the closest between the rows.
In this example, I have rows of order data, and when a company first set up an account and then a column with the number of days it took for a certain order to be made after they joined.
I need to select order lines where the number of days between joining and ordering are closest.
e.g.
customer date_joined order_date days_between_joining_ordering
1 1/1/2007 10/1/2007 9
1 1/1/2007 12/1/2007 11
1 1/1/2007 12/1/2007 11
1 1/1/2007 20/1/2007 19
2 1/1/2007 1/2/2007 0
2 1/1/2007 11/2/2007 10
2 1/1/2007 30/2/2007 30
So what I am looking to end up with in the results is:
customer date_joined order_date days_between_joining_ordering
1 1/1/2007 12/1/2007 11
2 1/1/2007 11/2/2007 10
So I need one row per customer but where the customers days_between_joining_ordering are the closest together.
Any ideas on how I can get this through SQL or PL/SQL??
Thanks
Daniel
I'm not sure what criteria you want used to uniquely identify each record, so I just used Patient_ID and FU_Days.
Anyway with the supplied data this provides the requested output, though I expect you have more than 2 patients in your full dataset. Are you wanting the two closest records for each possible pairing of patients? Or the lowest ranked records for any given patient relative to all the other patients?
For the first you could probably use this query:
set echo on
with INT_MATCH_TCES as
(select 1 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('10/01/2007','dd/mm/yyyy') post_vl_date, 291 fu_days from dual union all
select 1 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('12/01/2007','dd/mm/yyyy') post_vl_date, 239 fu_days from dual union all
select 1 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('12/01/2007','dd/mm/yyyy') post_vl_date, 160 fu_days from dual union all
select 1 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('20/01/2007','dd/mm/yyyy') post_vl_date, 89 fu_days from dual union all
select 2 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('01/02/2007','dd/mm/yyyy') post_vl_date, 301 fu_days from dual union all
select 2 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('01/02/2007','dd/mm/yyyy') post_vl_date, 320 fu_days from dual union all
select 3 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('01/02/2007','dd/mm/yyyy') post_vl_date, 321 fu_days from dual union all
select 3 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('01/02/2007','dd/mm/yyyy') post_vl_date, 325 fu_days from dual)
, ranking as (
select l.patient_id lid, r.patient_id rid, l.fu_days ldays, r.fu_days rdays,
abs(l.fu_days - r.fu_days) delta,
rank() over (partition by l.patient_id, r.patient_id order by abs(l.fu_days - r.fu_days)) rnk,
least(l.patient_id,r.patient_id) o1,
greatest(l.patient_id,r.patient_id) o2
from INT_MATCH_TCES l, INT_MATCH_TCES r
where l.patient_id <> r.patient_id
select a.*, delta
from INT_MATCH_TCES a, ranking
where a.patient_id = lid
and a.fu_days = ldays
and rnk = 1
order by o1,o2, a.patient_id
PATIENT_ID DRUG_LIST PR_MUTATIONS RT_MUTATIONS POST_VL_DATE FU_DAYS DELTA
1 3TC+ABACAVIR+AZT * 101E 10-JAN-2007 291 10
2 3TC+ABACAVIR+AZT * 101E 01-FEB-2007 301 10
1 3TC+ABACAVIR+AZT * 101E 10-JAN-2007 291 30
3 3TC+ABACAVIR+AZT * 101E 01-FEB-2007 321 30
2 3TC+ABACAVIR+AZT * 101E 01-FEB-2007 320 1
3 3TC+ABACAVIR+AZT * 101E 01-FEB-2007 321 1
6 rows selectedfor the second just rank patient_id from the previous results by the delta e.g.:
set echo on
with INT_MATCH_TCES as
(select 1 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('10/01/2007','dd/mm/yyyy') post_vl_date, 291 fu_days from dual union all
select 1 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('12/01/2007','dd/mm/yyyy') post_vl_date, 239 fu_days from dual union all
select 1 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('12/01/2007','dd/mm/yyyy') post_vl_date, 160 fu_days from dual union all
select 1 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('20/01/2007','dd/mm/yyyy') post_vl_date, 89 fu_days from dual union all
select 2 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('01/02/2007','dd/mm/yyyy') post_vl_date, 301 fu_days from dual union all
select 2 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('01/02/2007','dd/mm/yyyy') post_vl_date, 320 fu_days from dual union all
select 3 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('01/02/2007','dd/mm/yyyy') post_vl_date, 321 fu_days from dual union all
select 3 patient_id, '3TC+ABACAVIR+AZT' drug_list, '*' pr_mutations, '101E' rt_mutations, to_date('01/02/2007','dd/mm/yyyy') post_vl_date, 325 fu_days from dual)
, ranking as (
select l.patient_id lid, r.patient_id rid, l.fu_days ldays, r.fu_days rdays,
abs(l.fu_days - r.fu_days) delta,
rank() over (partition by l.patient_id, r.patient_id order by abs(l.fu_days - r.fu_days)) rnk,
least(l.patient_id,r.patient_id) o1,
greatest(l.patient_id,r.patient_id) o2
from INT_MATCH_TCES l, INT_MATCH_TCES r
where l.patient_id <> r.patient_id
, ranking2 as (
select a.*, delta,
rank() over (partition by a.patient_id order by delta) rnk2
from INT_MATCH_TCES a, ranking
where a.patient_id = lid
and a.fu_days = ldays
and rnk = 1
order by o1,o2, a.patient_id
select * from ranking2 where rnk2=1
PATIENT_ID DRUG_LIST PR_MUTATIONS RT_MUTATIONS POST_VL_DATE FU_DAYS DELTA RNK2
1 3TC+ABACAVIR+AZT * 101E 10-JAN-2007 291 10 1
2 3TC+ABACAVIR+AZT * 101E 01-FEB-2007 320 1 1
3 3TC+ABACAVIR+AZT * 101E 01-FEB-2007 321 1 1
3 rows selected
Similar Messages
-
How to get selected row index of a Table ?
hi gurus,I'm new to Webdynpro for abap
I'm displaying just Flight details in a Table so
how to get selected row index of a Table and need to be display in Message manager.Hi,
For getting the row index use the following code.
DATA lo_nd_node TYPE REF TO if_wd_context_node.
DATA lo_el_node TYPE REF TO if_wd_context_element.
DATA index TYPE i.
* navigate from <CONTEXT> to <NODE> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
lo_el_node = lo_nd_node->get_lead_selection( ).
index = lo_el_node->get_index( ).
node is the name of the node which is binded to the table.
For printing the message u can use code wizard.
Press ctrl-F7. Now Select generate message.
IN this select the method REPORT_SUCCESS
In the code now u can give index to Message text Exporting parameter. Comment receiving parameter.
Write the whole code in onLeadSelect of the table.
Regards,
Pankaj Aggarwal -
How to get selected row keys from RichSelectManyCheckbox
Adf Table has getSelectedRowKeys but SelectManyChekcbox does not has anything similar. Can you tell me how to get selected row keys programmatically for RichSelectManyCheckbox?
Hi User,
selectManyCheckbox component's value property holds the selected items values. Bind this property to some bean variable(of type list) so that you can get the selected values by accessing the bean property.
Sireesha -
How to edit selected rows in a datagrid?
Hi all,
I am new to flex and I would like to know how to edit
selected rows( through check boxes) in a data grid. As of now the
whole data grid becomes editable.
Regards
Saran.This is not simple in Flex 2.0.
You will need to use a custom itemRenderer.
Search the net, perhaps someone has a component or sample
close to what you want.
Tracy -
How can can I determine where email templates are used?
How can can I determine where email templates are used?
Here is a SQL query which was recently provided in response to a YES! question.
1. E-mails attached to the "Notify when plan cancelled":
select
da.Name as ServiceGroupName,
ds.Name as ServiceName,
dp.Subject as MonitorTaskName,
de.LogicName as Event,
demt.name as EmailTemplateName
from
defevent de,
defemailtemplate demt,
defeventtrigger det,
defproject dp,
defservice ds,
defarea da
where
det.objectid = 21 and
det.objectinstid = dp.projectid and
de.eventid = det.eventid and
demt.emailtemplateid = det.templateobjectinstid and
ds.serviceid = dp.ownerinstid and
da.areaid = ds.areaid
2. E-mails attached to all delivery plan tasks:
select
da.Name as ServiceGroupName,
ds.Name as ServiceName,
dt.Name as TaskName,
de.LogicName as Event,
demt.name as EmailTemplateName
from
defevent de,
defemailtemplate demt,
defeventtrigger det,
deftask dt,
defproject dp,
defservice ds,
defarea da
where
det.objectid = 46 and
det.objectinstid = dt.taskid and
de.eventid = det.eventid and
demt.emailtemplateid = det.templateobjectinstid and
dp.projectid = dt.projectid and
ds.serviceid = dp.ownerinstid and
da.areaid = ds.areaid
3. E-mails attached to all approval tasks:
select
da.Name as ServiceGroupName,
ds.Name as ServiceName,
dwsr.Subject as ApprovalReviewStep,
de.LogicName as Event,
demt.name as EmailTemplateName
from
defevent de,
defemailtemplate demt,
defeventtrigger det,
defworkflowsteproles dwsr,
defservice ds,
defarea da
where
det.objectid = 57 and
det.objectinstid = dwsr.steproleid and
de.eventid = det.eventid and
demt.emailtemplateid = det.templateobjectinstid and
ds.serviceid = dwsr.ownerid and
da.areaid = ds.areaidJust add a line to the "where" clause to specifiy which service(s) you want to run this for rather than for the whole catalog:
--By Service Name
ds.Name = "My Service Name"
--By Service ID (Multiple services can be returned.)
ds.ServiceID IN ('1', '2', '3') -
How to get selected Row Index in a table based ona VO?
Hi All,
I'm writing an ADF form wherein I use a VO based on a SQL query. I'd like to know how to get the index of a selected row. I havea selection Listener in place where I can print the selected Row's data using getSelectedRowData().toString() on the table.
How can I get certain Attributes from this selected row.
One solution I thought of is to get the row index and then read attributes. But I cant seem to figure out how to get rowIndex for a selected row. Any sugestions?
Using JDeveloper 11g.
Thanks
P.If your selected row is marked as current row you can use
// Get a attribute value of the current row of iterator
DCIteratorBinding iterBind= (DCIteratorBinding)dcBindings.get("testIterator");
String attribute = (String)iterBind.getCurrentRow().getAttribute("field1");Where 'testIterator' is the name of the iterator you use for the table and 'field1' is the name of an attribute you want to get.
Or you can iterate over the selected row keys (even if it's only one):
// get selected Rows of a table 2
for (Object facesRowKey : table.getSelectedRowKeys()) {
table.setRowKey(facesRowKey);
Object o = table.getRowData();
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)o;
Row row = rowData.getRow();
TestRow testRow = (TestRow)((DCDataRow)row).getDataProvider() ;
}Where TestRow is the row type of the VO of your table.
Timo -
ALV - How to set selected rows into internal table
Hi all,
I am tying to set with an 'X' flag the selected rows in my ALV using an internal table that contains all rows showed.
More exactly I have tried to follow these steps.
1) I have added the filed SEL (type SEL) to my ALV structure zrt_bo_slabsend and I defined my internal table in this way
DATA: gt_report TYPE STANDARD TABLE OF zrt_bo_slabsend,
gw_report TYPE zrt_bo_slabsend.
2) I have set gw_layo-box_fname = 'SEL' to gw_layo (ALV layout)
Pressing the "delete button" that I have insert on the top of the ALV, I intercept correctly my user command and I call a form (named "delete_lines") where I have this abap code
FORM delete_lines.
DATA: l_subrc LIKE sy-subrc,
lw_grid_settings LIKE lvc_s_glay.
gw_layo-box_fname = 'SEL'.
"set field name to store row selection
gw_layo-edit = 'X'. "makes whole ALV table editable
gw_layo-zebra = 'X'.
gv_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY_LVC'
exporting
i_callback_program = gv_repid
i_callback_pf_status_set = gc_status
i_callback_user_command = gc_user_command
is_layout_lvc = gw_layo
it_fieldcat_lvc = gw_fkat
i_grid_settings = lw_grid_settings
i_save = 'X'
is_variant = variant
it_events = gt_events
TABLES
t_outtab = gt_report
EXCEPTIONS
program_error = 1
OTHERS = 2.
LOOP AT gt_report ASSIGNING <report> WHERE SEL = 'X'.
DELETE gt_report.
ENDLOOP.
ENDFORM.
I'd like to select many rows in my ALV report, than by pressing the delete button I'd like to see a refresh of my ALV, without the selected rows. I want to save it only at the end of my action, only by pressing the save button.
Any suggestion about the abap code will be well appreciated.
Thanks in advance for your kind help.
Regards.
GiovanniHi Giovanni,
I am using the method:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM = gd_REPID
I_CALLBACK_PF_STATUS_SET = 'UDIT'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Mainatin cell entry'
* I_GRID_SETTINGS =
IS_LAYOUT_LVC = GS_LAYOUT
IT_FIELDCAT_LVC = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
* IT_SORT_LVC =
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
I_DEFAULT = 'X'
* I_SAVE = 'X'
* IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
I_SCREEN_START_COLUMN = 30
I_SCREEN_START_LINE = 14
I_SCREEN_END_COLUMN = 120
I_SCREEN_END_LINE = 25
* IT_EXCEPT_QINFO_LVC =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_ZCP_DEMAND_SYS1
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I have made five buttons on my toolbar (add, delete, save, back, exit).
Kindly tell me how can I catch the sy-ucomm of these buttons.
NOTE: this FM is written inside an user-exit, so I cannot make forms.
Thanks in advance. -
How to find selected rows in REUSE_ALV_GRID_DISPLAY
HEllo All,
In OO we have a method to find get_selected_rows but i am unable to what is the way to find selected rows in REUSE_ALV_GRID_DISPLAY.
I am able to find a single row but i have to find multiple cleans in ALV. How can i do this.
Please help me with some ideas or please post some sample codes.
Regards,
LisaHi,
Check this code..
REPORT zdayatest1.
TABLES :t247.
TYPE-POOLS slis. "Type definitions for alv report
TYPES: BEGIN OF ty_func_tab,
fcode TYPE rsmpe-func,
END OF ty_func_tab.
DATA: it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
DATA: is_lvc_s_glay TYPE lvc_s_glay.
DATA: wa_layout TYPE lvc_s_layo.
DATA: is_rxtab TYPE ty_func_tab.
DATA: BEGIN OF it_final OCCURS 0,
check(1),
mnr LIKE t247-mnr,
ltx LIKE t247-ltx,
END OF it_final.
DATA: wa_final LIKE it_final.
DATA: w_repid LIKE sy-repid.
START-OF-SELECTION.
w_repid = sy-repid.
REFRESH it_final.
SELECT mnr ltx
FROM t247
INTO CORRESPONDING FIELDS OF TABLE it_final
WHERE spras EQ 'E'.
wa_fieldcat-fieldname = 'CHECK'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-outputlen = '3'.
wa_fieldcat-col_pos = '1'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MNR'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-outputlen = '8'.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-coltext = 'Month'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LTX'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-outputlen = '20'.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-coltext = 'Month Desc'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = w_repid
i_callback_pf_status_set = 'SUB_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = 'TESTING'
is_layout_lvc = wa_layout
it_fieldcat_lvc = it_fieldcat
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*& Form USER_COMMAND
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
IF selfield-fieldname = 'CHECK'.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
LOOP AT it_final WHERE check = 'X'.
IF it_final-check IS INITIAL.
it_final-check = 'X'.
ELSE.
CLEAR it_final-check.
ENDIF.
MODIFY it_final.
ENDLOOP.
selfield-refresh = 'X'.
ENDIF.
ENDFORM. "USER_COMMAND
*& Form sub_pf_status
* text
* -->RT_EXTAB text
FORM sub_pf_status USING rt_extab TYPE slis_t_extab. "#EC CALLED
CLEAR is_rxtab.
is_rxtab-fcode = 'TEST'.
APPEND is_rxtab TO rt_extab.
SET PF-STATUS 'PF_STATUS' ."EXCLUDING rt_extab.
ENDFORM. "sub_pf_status -
How to get selected row from a non-bind ADF table
Hi,
I have an ADF table that is based on a collectionModel built programmatically. The collectionModel is this:
model = new SortableModel(new ArrayList<ArrayList>());
Hence, it is not a binding table. My question is how to get the selectedRows from a non-bind table.
I am used to building binding ADF table and I know we can get it from voiterator.getCurrentRow, since the selectionListener is set to the binding....collectionModel.makeCurrent
<af:table value="#{bindings.ItasLookupTypesVO1.collectionModel}"
selectedRowKeys="#{bindings.ItasLookupTypesVO1.collectionModel.selectedRow}"
selectionListener="#{bindings.ItasLookupTypesVO1.collectionModel.makeCurrent}"
</af:table>
I am thinking maybe I need to write my own selectionListener, but need more advice/ideas of what's the codes in the customer selection Listener to get it from my SortableModel.
Please help.
Thanks
-MinaI'm not sure if this works in your case, but check out the selection listener I write in this blog http://wp.me/pcBZk-eu
You should use the selection event and check the added set. This should give you access to the selected row.
Timo -
How to get selected Row/Cell value in i5Grid
Hi Friends,
Can anyone help to how to find the selected Row/Cell value of a i5Grid object. I am able to register the event handlers which are getting invoked on row/cell selection. But I want to know how can I get the value of selected Cell/Row. I would like to add selected Items from one i5Grid to another one.
So want to know how can I get and set the value of i5Grid object.
MII version 14.0 SP4 Patch
Thank in advance
Shaji ChandranHi Shaji,
Here is my code.
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Your Title Here</TITLE>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<META http-equiv='cache-control' content='no-cache'>
<META http-equiv='expires' content='0'>
<META http-equiv='pragma' content='no-cache'>
<SCRIPT type="text/javascript" src="/XMII/JavaScript/bootstrap.js" data-libs="i5Chart,i5Grid,i5SPCChart"></SCRIPT>
<SCRIPT>
var Grid = new com.sap.xmii.grid.init.i5Grid("STC/C5167365/i5Grid_TagQuery", "STC/C5167365/TagQuery");
Grid.setGridWidth("640px");
Grid.setGridHeight("400px");
Grid.draw("div1");
function setCellValue()
Grid.getGridObject().setCellValue(1,1,"Set");
function setCellValueAgain()
Grid.getGridObject().setCellValue(1,1,"Changed Again");
</SCRIPT>
</HEAD>
<BODY>
<DIV id="div1"></DIV>
<INPUT type="Button" value="setCellValue" onClick="setCellValue()"/>
<INPUT type="Button" value="setCellValueAgain" onClick="setCellValueAgain()"/>
</BODY>
</HTML>
Regards,
Sriram -
How to get selected row data of an ADF table in HashMap?
Hi,
Can anyone please tell me how to selected row data of an ADF table in HashMap like :
Object obj = pageTable.getSelectedRowData();
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)obj;
Now in above code I want the convert rowData in HashMap.
Can anyone please tell me how to do that? Its urgent.
Thanks,
VikVik,
No need to ask the same question 3 times...
In [url http://forums.oracle.com/forums/message.jspa?messageID=4590586]this post, Nick showed you how to get the Row.
If it were so urgent, you could have done a little reading of the javadocs to come up with code like this (not tested, up to you to do that)
HashMap m = new HashMap();
Row r = get it like Nick showed you to;
Object values[]=r.getAttributeValues();
String names[]=r.getAttributeNames();
for (int i=0; i<r.getAttributeCount(); i++)
m.put(names, values[i]); -
How to control selected row in result table on a search page?
Using JDeveloper 10.1.3.2.0
I have attempted to create an ADF page that contains a search and result table in the same page.
I have questions related to the result table. Let's say the result table shows 10 rows per page.
If I page forward there is no default selected row "clicked" on the page. Only if you return to
the very first 10 rows do you see a default selection in row number one of the results.
How would I go about making the first row of each page the default selection?You'll need to code this into the RangeChangeEvent event of the table.
http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/apidocs/oracle/adf/view/faces/component/core/data/CoreTable.html
That said - I'm not sure this will be very helpful for the end user - after all in any case they'll need to first select a row before doing an operation on it. -
How To Edit Selected Row In ALV Table
Hello Experts,
In My Webdynpro Application, I am displaying records from database table into an ALV Table.
I want to edit only selected record from ALV table.
Please Suggest How to achieve this.
Thanks,
PratibhaThe link given above is for the UI element 'Table' and does not pertain to ALV.
To Make an ALV Editable on lead selection for that particular lead selected row.
1. The ALV should be made lead selectable, when initializing
2. The ON_LEAD_SELECT function should be invoked.
3. Withing this function the index has to be retrieved to know which row was selected.
4. Based on the index retrived all the columns have to pass FALSE to read_only in the column properties.
Regards,
Pramod -
Improving performance:How to know selected rows in af:table through chk box
Hi,
I've a VO which has 3 transient variables. 2 of these transient variables getting the values from a view accessor. Using the other transient variable in the Ui to select the rows in the af:table.
In my UI, I've a table and a Check Box to select the rows. I want to get the selected rows through the check box, in the backing bean for my business requirements.
I've used below logic to get the selected rows. Here, I am iterating through the entire viewobject rows, so it is impacting the performance of the UI. How can I know the selected rows in the bean? or How can I improve the performance?
I also applied below view criteria, but still its not performant.
// ViewCriteria vc = vo.createViewCriteria();
// //.getViewCriteriaManager().getViewCriteria("SelectedMerchantCriteria");
// ViewCriteriaRow vcr = vc.createViewCriteriaRow();
// vc.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE | ViewCriteria.CRITERIA_MODE_QUERY);//MerchantName1
// //vcr.setAttribute("MerchantName1", "1017 CAFE");
// vcr.setAttribute("SelectToMap", "true");
// vc.addRow(vcr);
// vo.applyViewCriteria(vc);
// vo.executeQuery();
public void mapSupplierMerchant2(ActionEvent actionEvent) {
// Add event code here...
OperationBinding method = null;
AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
Map pageFlowScope = adfFacesContext.getPageFlowScope();
ArrayList merchantMappingList = new ArrayList();
Long primaryVendorId = null, groupId = null;
CollectionModel tableModel = (CollectionModel) this.getMerchantTable().getValue();
JUCtrlHierBinding tableBinding = (JUCtrlHierBinding) tableModel.getWrappedData();
ViewObject vo = tableBinding.getViewObject();
// ViewCriteria vc = vo.createViewCriteria();
// //.getViewCriteriaManager().getViewCriteria("SelectedMerchantCriteria");
// ViewCriteriaRow vcr = vc.createViewCriteriaRow();
// vc.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE | ViewCriteria.CRITERIA_MODE_QUERY);//MerchantName1
// //vcr.setAttribute("MerchantName1", "1017 CAFE");
// vcr.setAttribute("SelectToMap", "true");
// vc.addRow(vcr);
// vo.applyViewCriteria(vc);
// vo.executeQuery();
List<JUCtrlHierNodeBinding> merchantList = (List<JUCtrlHierNodeBinding>)tableBinding.getChildren();
JUCtrlHierNodeBinding merchantNode = null;
List supToMap = new ArrayList();
boolean isMerchantSelected = false, isMasterSup = false;
Long merchantIdToMap = null, masterSupId = null;
Row r = vo.first();
while(r!=null) {
System.out.println("================================ " + r.getAttribute("MerchantName1") + " " + r.getAttribute("SelectToMap") );
if(r.getAttribute("SelectToMap")!=null) {
isMerchantSelected = (Boolean) r.getAttribute("SelectToMap");
if(isMerchantSelected) {
merchantIdToMap = (Long) r.getAttribute("MerchantMapId");
if(merchantIdToMap!=null) merchantMappingList.add(merchantIdToMap);
r = vo.next();
if(merchantMappingList.size()>0) {
primaryVendorId = (Long) pageFlowScope.get("primaryVendorId");
groupId = (Long) pageFlowScope.get("groupId");
method = (OperationBinding) ADFUtil.findOperation("mapSupplierMerchant");
if(method!=null) {
Map paramMap = method.getParamsMap();
paramMap.put("vendorId", primaryVendorId);
paramMap.put("groupId", groupId);
paramMap.put("merchantList", merchantMappingList);
Boolean result = (Boolean) method.execute();
List errors = method.getErrors();
if(result!=null && result) {
this.getMerchantMappedFlag().setValue(true);
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getMerchantMappedFlag());
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getMerchantTable());
tableBinding.getViewObject().setRangeSize(25);
FacesMessage message = new FacesMessage("The selected merchants have been mapped to the group. Please save the changes. " );//+ adfFacesContext.getPageFlowScope().get("merchantGroupName") );
message.setSeverity(FacesMessage.SEVERITY_INFO);
FacesContext.getCurrentInstance().addMessage(null, message);
} else {
FacesMessage message = new FacesMessage("No merchants have been selected for mapping. Please select atleast one merchant." );//+ adfFacesContext.getPageFlowScope().get("merchantGroupName") );
message.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext.getCurrentInstance().addMessage(null, message);
}Hi
Please check this post [http://adfwithejb.blogspot.in/2012/08/hi-i-came-across-one-common-use-case.html].
It has clear explanation of how to provide a checkbox for selection of rows. You can also go through my comments at the end of the post. That should solve your problem of iterating through the entire VO.
Thanks,
Rakesh -
How to hide selected rows on Dashboard
Hello.
Assume there is table having about 10 rows. The goal is to let the user select random rows, click on them and make them disappear from the dashboard.
The user wants to export the dashboard to PDF but each time he needs to hide some of the table rows before export is done. There is no rule which rows should be hidden and which should be visible - user selects rows randomly, based on his current needs (or maybe based on the current weather and his grandmother shoe size, i don't know.)
Is there a way to achieve this?
Thanks for your help.
KubaFirst the quick answer: no, you can't select a row and make it disappear. But depending on how many columns are in the report and whether every instance of a certain type of row needs to be deleted, you can try this:
I'll take the worst case scenario. Every column in the report can have multiple values that need to be excluded.
1) Build multi-select prompts on each column with the operand "not in/not equal to."
2) Put "Is prompted" on all the columns.
When the user discovers a value in a column that makes him want to get rid of that row (and all rows with that value), he can select it in the prompt. When he hits the "Go" button, the prompts will filter out all those rows.
If each row is completely independent of all other rows, then you're out of luck. I would say, download the report in Excel. Delete rows, then convert to pdf.
Maybe you are looking for
-
How to restrict the maximum size of a java.awt.ScrollPane
Dear all, I would like to implement a scroll pane which is resizable, but not to a size exceeding the maximum size of the java.awt.Canvas that it contains. I've sort of managed to do this by writing a subclass of java.awt.ScrollPane which implements
-
? using multiple approval signatures, each locking the fields with collections
Having fun with LiveCycle to make a "signoff" sheet that will allow a customer to request a "new product" with a PDF form. Once that information is added to our EDR (Eng Design Request) form, I want the form to be forwarded to multiple departments, w
-
Bluetooth problems all around - Modem in the first row.
Hi there, I've got a really annoying problem with the Bluetooth Setup of my Mac. Like you can see in my system description, I use Mac OS X 10.5.6. For a long time I used my old mobile via Bluetooth and GPRS as a Modem. Now it was time for a change. I
-
The touch screen keyboard of my blackberry
Recently the touch screen keyboard if my blackberry torch has stopped working when I close the my phone (slide close) and also the rotation that Blackberry torch does when you change the position of it isn't also work, I thought it was software probl
-
Longstanding problem with Sleep causing Bomb
Hello, iMac Intel Core 2 Duo running X v10.4.11 all updates applied whenever system says they're available no peripherals The problem is a simple one to describe: if I put the iMac to sleep manually all is well. If I leave the iMac to its own devices