Hi all,

I want to read the content of my current grid row when user double clicks on that row. Kindly explain with some example.

Thanks and regards.

George.

asked 06 Mar '13, 23:20

George's gravatar image

George
1111229
accept rate: 0%


Hi George,

You can read the content of the current grid row in the doubleClick event of the grid component, through the api_datasource.getRow API.

Consider the following grid:

<grid dataSource="gridDatasource" name="grid">
  <events>
    <doubleClick action="gridDoubleClick"/>
  </events>
  <column>
     <textField column="COL1"/>
  </column>
  ...
</grid>

The simple gridDoubleClick procedure can be as follows:

procedure gridDoubleClick is
  v_row_t api_datasource.tt_row;
begin
  v_row_t := api_datasource.getRow('gridDatasource');
  api_application.showpopupmessage('value: '|| v_row_t('COL1').value_tx);
  ...
end;

The procedure above is useful when the grid and its datasource is fixed. If you need a generic procedure, you can use the following:

procedure gridDoubleClick is
  v_gridName_tx       varchar2(1000);
  v_datasourceName_tx varchar2(1000);
  v_row_t             api_datasource.tt_row;
  v_columns_t         api_datasource.tt_columns;
  v_columnName_tx     varchar2(255);
begin
  -- get double-clicked grid name
  v_gridName_tx       := api_application.getFocusedComponent;
  -- get datasource of the grid
  v_datasourceName_tx := api_component.getDatasource(v_gridName_tx);
  -- get current row of the datasource 
  v_row_t             := api_datasource.getRow(v_datasourceName_tx);
  -- get column list of the datasource
  v_columns_t         := api_datasource.getColumnNames(v_datasourceName_tx);
  -- column values for the current row
  for i in 1..v_columns_t.count loop
    v_columnName_tx := v_columns_t(i).name_tx;
    case v_columns_t(i).datatype_cd
      when 'VARCHAR2' then
        api_application.showpopupmessage('value: '||v_row_t(v_columnName_tx).value_tx);
      when 'NUMBER' then
        api_application.showpopupmessage('value: '||v_row_t(v_columnName_tx).value_nr);
      when 'DATE' then
        api_application.showpopupmessage('value: '||v_row_t(v_columnName_tx).value_dt);
      when 'CLOB' then
        ...
      when 'BLOB' then
        ...
    end case;
  end loop;
end;

Hope this helps,
Ibrahim

link

answered 07 Mar '13, 03:16

Ibrahim%20Sandalli's gravatar image

Ibrahim Sand... ♦♦
1.5k5
accept rate: 25%

edited 07 Mar '13, 03:17

Thank you Mr. Ibrahim.

(07 Mar '13, 22:17) George

Hi Ibrahim,

This was a very helpful piece of code to me especially the generic one. Thank you very much and may God bless you.

George.

(08 Mar '13, 03:49) George
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×19
×7
×2
×1

Asked: 06 Mar '13, 23:20

Seen: 1,162 times

Last updated: 08 Mar '13, 03:49


© Copyright Gerger 2017