How to make a Jtable's row selected thru program

Hi , in my application few of the rows (not continous)
need to get selected automatically when the jTable is intially shown.
I did this using table.setRowSelectionInterval(0,2)
This method works fine selecting all the rows from 0 th to 2 th row,
but if i want only 0 th and 2 th ( excluding the 1 st row ) to be selected , i dont know how to do that???
i tried the following also
//indeces of rows to be selected in the table are stored
//in array
int[] array = new int [2];
parray [0]= 0;
parray [1]= 2;
table.setRowSelectionInterval(parray[0], parray[0] );
table.setRowSelectionInterval(parray[2], parray[2] );
//for each iteration a single row will be selected
//coz the starting and ending indeces are same ie
(parray[0],parray[0])
but when this code is run only the 2 nd row gets selected , what abt the 0'th row???
please help.
Thanx.

sorry
there is a small correction in the above code
//indeces of rows to be selected in the table are stored
//in parray
int[] parray = new int [2];
parray [0]= 0;
parray [1]= 2;
table.setRowSelectionInterval(parray[0], parray[0] );
table.setRowSelectionInterval(parray[1], parray[1] );
//for each iteration a single row will be selected
//coz the starting and ending indeces are same ie
(parray[0],parray[0])

Similar Messages

  • How to make the default tree row selection programatically

    I have one use case where I am displaying the tree table based on some parameter which is just for filtering the table and display the part of hierarchy.
    The problem here is I want to make a default selected row when the tree will be rendered to UI based on the primary key(that is the input parameter).
    can you please tell me how to do this.I am using jdev 11g.
    thanks,
    Harsh

    Hi,
    for this you need to know where in the path the PK is. If e.g. the PK is for a second level node then you need to pass the first level node PK as well. Nodes in a tree are defined as ArrayLists. So unfortunately your question doesn't provide enough information
    Frank

  • How to make a procedure from a select statement please.....

    Dear All,
    i am new to oracle db, but i do have nice knowledge on sql in sql server, could you please help me.,,,,, in the below issue
    i do have below query in oracle db just joining two views,
    select docview.firstname as "First Name", docview.lastname as "Last Name", docview.mrn as "MRN", docview.physician as "Physician", docview.surgicalcong "Surgical Consent Missing", docview.admissionnotemissing "Admin Assessment Missing",
    (case (docview.doctype) when 135 then 'Doctor Chart Checklist' else 'DS Chart Checklist' end) as doctypename,
    docview.hpmissing "History & Physical Missing", docview.nursingassessment "Nursing Admission/Assessment", docview.anesthesiologymissing "Anesthe Consultation Missing", docview.medicalevalmissing "Medical Evaluation Missing", docview.Doctorlabresultmissing "Doctor Lab Results Missing", docview.outsidelabresultmissing "Outside Lab Results Missing", docview.chestxraymissing "Chest X-Ray Missing",
    docview.ekgmissing "Ekg Missing", docview.cardioechomissing "Cardio Echo Missing",docview.stresstestmissing "Stress Test Missing", docview.pulmonaryfunctionmissing "Pulmonary Function Missing"
    from DoctorMainView docview inner join DoctoSurgicalView surgicalView on docview.accountid= surgicalView.accountid and docview.mrn= surgicalView.mrn and docview.physician = surgicalView.physician
    and docview.lastname=surgicalView.lastname
    where docview.doctype in (23,61)
    Order by docview.firstname
    how can i make a procedure with below two steps,
    1) load the result of above query to some temp table / or even a fixed table (which ever easier)
    2) list all data from the temp table / fixed table created in first step
    so in the final expecting result is
    execute myprocnamehere -- will result same as running above query
    please help me
    thanks a ton in advance
    i greatful to you all
    Best Regards
    Buzzi

    Why would you want to extract all of the results from the database and write them to a table just so you could read them back out again? Wouldn't it be simpler just to return the results in one shot?
    In general the procedure and call would look something like this:
    SQL> create or replace procedure myprocnamehere
      2     ( p_results out sys_refcursor )
      3  as
      4  begin
      5     open p_results for
      6        select 'Results here' as results from dual;
      7  end;
      8  /
    Procedure created.
    SQL> var myresultset refcursor
    SQL>
    SQL> call myprocnamehere(:myresultset);
    Call completed.
    SQL> print :myresultset
    RESULTS
    Results here
    1 row selected.Edited by: William Robertson on Feb 8, 2011 7:13 PM

  • How to make a whole table row be read at once?

    Hi,
    I want to make a whole table row be read at once by screenreaders if the table is not editable?
    I tried to use "getAccessibleSelection" and return a own implementation which returns the number of columns at "getAccessibleSelectionCount".
    But if "getAccessibleSelectionCount" return anything else than 1, the method "getAccessibleSelection" is never called.
    Does anybody have a idea or a suggestion to solve this problem?
    Thanks in advance

    Hi AJL,
    If you mean a table of data values in the Data Portal, i.e. a list of channels, then yes you can do it. In that case you should just register load the channels you want to be read-only. You can do this interactively by right-clicking on the data file in question and select "Register data". You can also double-click on the file to select individual channels to load or register. Programmatically, this looks like
    Call DataFileLoad(DataFilename, DataPluginName, ImportAction)
    Setting ImportAction = "Register" will register load the channels. If dragging and dropping the data file loads it correctly, then you can set DataPluginName = "". Otherwise, you can specify there which DataPlugin to use for the import process.
    You can also programmatically selectively load some of the channels from the data source:
    Call DataFileLoadSel(DataFilename, FileImportFilter, ImportSelection, ImportAction)
    The "ImportSelection" parameter works just like the CNo() function in DIAdem:
    "GroupName/ChannelName"
    "GroupName/[ChannelIndex]"
    "[GroupIndex]/ChannelName"
    "[GroupIndex]/[ChannelIndex]"
    If, on the other hand, you mean a read-only table in the REPORT panel, your options are limited, though you can do that with a SUDialog.
    Regards,
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • How to make validation in Bean and select value from another table

    I want to know how to select data from table in backing bean according to primary key i have
    the problem is that
    i have a table Employee_Salary contains Employee ids and their salary
    Empoloyee_Salary table
         Employee_ID      Number
         Employee_salary Number
    And Another table Called Employees
    Employees table
         Employee_ID     Number
         IsManager Varchar2 its value is [*Yes or NO*]
    and other columns that i don't care about this table
    i have on a jsff page an <af:table> this table is editable this is the Empoloyee_Salary table
    *i want to check before save or after insert if this employee is Manager [from Employees tabke(yes or no)] the salary*
    cannot be less that 100
    i want to know how to make this how to select the value from employees table according to the id i have in the employee_salary table how to make this and make this validation
    i have to select IsManager from Employees Table to see if this manager or no
    i want to know how to make this in a bean
    i use jdeveloper 11g
    and my project is ADF Fusion project
    and the page that have the Emplpyee_Salary table is JSFF
    thanks in advance

    You might want to write this code in a validator on the entity object if it should apply from every screen.
    If you want to access view objects from a backing bean the basics are here: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcservices.htm#sthref918

  • How to capture indexes of multiple rows selected in Advance list

    Hi,
    - I have a prefilled advance list with multiselection enabled.
    - There is a button, associated with an action,which is bind to a eventHandler,that event Handler has script operation which conains the ruby scrpt code.
    - Now when i select multiple rows of that advance list and click on the action,I want to capture the indexes of all the selected rows.
    I tried using following ruby code:
    lead=$data.datalist.LeadSelectedIndex
    But it returns index of only first row selected out of various rows selected.
    So please anyone help me on that.
    Regards ,
    Saurabh Sharma.

    In FP2.6 there is no chance from SDK to have a mass enabled Action and bind to a mulli selection list as a BO Action in the UI Designer, as multiplicity will always be single and only lead selection would be selected.
    this feature comes only in FP3.0.
    So i am not sure what excatly Saurabh wants to do : maybe do some calculations based on multi seletions then i would do the following as also what Christian mentioned
    multiSelect =  ($data.DataList.GetSelectedRowsCount() > 1);
    NoOfRowsSelected = $data.DataList.GetSelectedRowsCount();
    SummationField = 0;
    if ( multiSelect )
       LeadSelection = $data.DataList.LeadSelectedIndex;
       RequiredDataField = $data.DataList.Get(LeadSelection).AnydataField;
       for i in 0..(NoOfRowsSelected - 1)
         currentRow = LeadSelection + i;
          RequiredDataField = $data.DataList.Get(currentRow).AnydataField;
    // imagine this is just add values of the RequiredDataField
         SummationField = SummationField +   RequiredDataField
       end
    end
    So i have not tried this directly - but i hope i make the idea clear.
    Regards,
    Nitesh Pai

  • How to make nested JTable

    Hi.
    Does anyone know how to make nested table.
    Just like in MS access, if one row of data in a table has the same key as another set of data in other table you can expand the row so that it show an other table of data inside it. the popup table also has the Table header of its own. I have looked at TreeTable tutorial but i don't know how to extend that to nested table.

    hi, define a tablecellrenderer for your table(me be one type per row) and let him bring back your popup table in that cells(rows) you want.

  • How to chop the line "25 rows selected"

    Hi all,
    I am creating reports by connecting Oracle from a shell script using spool,however everything is ok.
    how do I chop the line "25 rows selected" at the end of report?
    Any suggestion!!!!

    set feed off
    before the query.

  • How to avoid table refresh on row selection

    Hi,
    I have a table where the row selection happens on selecting the check box in the first column of the row. The check box is bound to the transient Boolean attribute of my VO to support this functionality which is missing in new version of ADF. The selection is working fine, however I am facing the issue with table refresh. Everytime I click checkbox to select or unselect a row my whole table is getting refreshed which is very unusual for user point of view. This is my code for the checkbox column:
    <af:column sortProperty="isSelected" sortable="true"
    headerText="#{bindings.pricingObjects.hints.isSelected.label}"
    id="c4"
    inlineStyle='#{(row.isSelected)?"background-color: #E7E7E7":""};'>
    <af:selectBooleanCheckbox value="#{row.bindings.isSelected.inputValue}"
    required="#{bindings.pricingObjects.hints.isSelected.mandatory}"
    shortDesc="#{bindings.pricingObjects.hints.isSelected.tooltip}"
    id="it4" simple="true"
    autoSubmit="true">
    <f:validator binding="#{row.bindings.isSelected.validator}"/>
    </af:selectBooleanCheckbox>
    I have to keep autoSubmit="true" on selectBooleanCheckbox because the table has to change color of the row everytime the checkbox is selected or deselected. Also, there are multiple commandToolbarButton such as "Delete" which needs to be enabled/disabled depending on the row selection.
    Is there anyway, I can achieve this behaviour with minimal refresh of table?

    Hi Marge,
    Yes I do have Add and Delete toolbar button in the panelCollection and also set partialTrigger="tableId" on them. I need this partialTriggers because Delete button should enable/disable depending on number of rows added in the table. However, I tried removing them but it did not work for me, table is still refreshing. BUT this solution does work in combination of other solution i.e. removing ChangeEventPolicy="ppr" on the iterator. I need ppr because I have a form which is bound to the same iterator and should change on table selection. The design is like this,
    - Read-only Table on top
    - Editable Form below
    - Select the row in table and edit the fields in the form
    If I remove ppr then my form is not updating with the row selection.
    Regards,
    Afroz

  • How to make sure newly created row is editable by default programatically

    Hi All,
    I got a problem with creating new row in single row selection table with on click property enabled for editing mode.
    Function requirement is like: I have Mater-Detail. While creating detail lines, line has to be created with default line number. Eg: Master1 can have line numbers 1,2,3..etc, Master2 can have 1,2,3.. etc.
    In applicationTable for Pattern Create
    Action Listener=”#{CreateAndEditFiscalDocumentBean.createChargeLine}”
    In Table rowSelection="single" and editingMode="clickToEdit"
    Here the problem is:
    When I first come to the page,the first row in the detail table is editable and could able to edit any other row on click . But When I create a new row , I got a new row with line number but it is not editable.
    I want it to be editable on create and previously selected row should be read only. I have tried several ways but nothing is working.
    My observation is, when I call the bean method in Action Listener of application Table in create patteren, I am facing this problem. If I do not call this method, it is working as expected. But I need to call this method because it has to create row with line number.
    I am putting below two scenarios which I have tried. I am not successful in the both the scenarios.
    Could you please help me in achieving expected functionality.
    Many thanks in advance for your time and help.
    Scenario 1:
    Jsff:
    ApplicationTable: createActionListener="#{CreateAndEditFiscalDocumentBean.createChargeLine}"
    Table: rowSelection="single", editingMode="clickToEdit"
    Bean Code:
    public void createChargeLine(ActionEvent actionEvent) {
    FacesContext fc = FacesContext.getCurrentInstance();
    ExpressionFactory factory = fc.getApplication().getExpressionFactory();
    MethodExpression method=factory.createMethodExpression(fc.getELContext(),"#{bindings.createChargeLine1.execute}",String.class,new Class[]{});
    method.invoke(fc.getELContext(),null);
    AMImpl Code:
    public void createChargeLine() {
    ViewObject itemChargeVO = this.getFiscalDocumentCharges();
    ViewObject fiscalDocumentHeaderVO = this.getFiscalDocumentHeader();
    Row toRow = fiscalDocumentHeaderVO.getCurrentRow();
    Row newRow = null;
    Row latestRow = itemChargeVO.first();
    Integer line_number = new Integer(0);
    int numberOfItemLines = 0;
    if (latestRow != null) {
    RowSet rs = itemChargeVO.getRowSet();
    numberOfItemLines = numberOfItemLines + 1;
    if (rs != null) {
    line_number =
    (Integer)rs.first().getAttribute("LineNumber");
    while (rs.hasNext()) {
    numberOfItemLines = numberOfItemLines + 1;
    Row row = rs.next();
    if (line_number.compareTo((Integer)row.getAttribute("LineNumber")) <
    0)
    line_number =
    (Integer)row.getAttribute("LineNumber");
    line_number = line_number + 1;
    newRow = itemChargeVO.createRow();
    newRow.setAttribute("LineNumber", line_number);
    itemChargeVO.insertRowAtRangeIndex(numberOfItemLines + 1, newRow);
    itemChargeVO.setCurrentRow(newRow);
    } else {
    newRow = itemChargeVO.createRow();
    newRow.setAttribute("LineNumber", new Integer(1));
    itemChargeVO.insertRowAtRangeIndex(0, newRow);
    itemChargeVO.setCurrentRow(newRow);
    Scenario 2:
    Bean method changes:
    public void createChargeLine1(ActionEvent actionEvent) {
    Row newLine = ApplicationsTableEventHandler.getInstance().processCreate(getChargeTable());
    newLine.setAttribute("LineNumber", new Integer(1));
    }

    Hi Jerry,
    Please refer to the following blog and check whether you followed all the steps:
    /people/harikrishna.sunku/blog/2008/12/18/work-center-and-navigation-link-creation-in-crm-2007
    You basically need to ensure that your custom work center is assigned to a navigation bar profile; and this navigation bar profile is assigned to your business role.
    Regards,
    Shiromani

  • How to make a rectangle around activeDocument.selection?

    Hi,everyone!
    Recently I met a awful problem. I want to make a rectangle around current selection, but Not success.
    Could you help me or give some clues? Thanks!

    Try the following code.
    Cheers Daniel
    boundingbox();
    function boundingbox()
        // zet nulpunt linksonder
        app.activeDocument.pageOrigin = Array(0,0);
        app.activeDocument.rulerOrigin = Array(0,0);
        // set variable
        var breedte = app.activeDocument.width;
        var hoogte = app.activeDocument.height;
        var doc = app.activeDocument;
        // omrekenfactor
        var omf = 2.834645;
        // maak lijnkleur aan
        var newRGBColor = new RGBColor();
        newRGBColor.red = 0;
        newRGBColor.green = 255;
        newRGBColor.blue = 0;
        var black = new GrayColor();
        black.gray = 100;
        var layercheck = 0;
        var targetDocument = app.activeDocument;
        var layerCount = targetDocument.layers.length;
        var a=1;
        for (var i=1 ; i < 2; i++) {
            if (a==1){var txt = ''; var layname = 'BB';};
            var layercheck = 0;
            for (u = layerCount -1; u >= 0; u--){
                targetLayer = targetDocument.layers[u];
                var layerName = new String (targetLayer.name);
                    if (layerName.indexOf(layname) == 0){
                    targetDocument.layers[u].visible= true;
                    targetDocument.layers[u].locked= false;
                    var layercheck = 1;
            if (layercheck == 0){
                newlayer = documents[0].layers.add();
                newlayer.name = (layname);
                newlayer.color = newRGBColor;   
        alignType = 'top';
        mySelection = activeDocument.selection;
            if (mySelection.length > 0) {
                anchorBounds = getPosition(mySelection[0]);
                var artLayer = doc.layers['BB'].groupItems.add();
                targetDocument.layers['BB'].preview = false;
                var breedte = bnds[2] - bnds[0];
                var hoogte = bnds[1] - bnds[3];
                var rect = artLayer.pathItems.rectangle ((bnds[1] + (20*omf)),(bnds[0] - (20*omf)), breedte + (40*omf), hoogte + (40*omf));
                rect.filled = false;
                rect.stroked = false;
            } else {
                anchorBounds = getDocPosition();
                var doc = app.activeDocument;
                var omtrekartwork = app.activeDocument.geometricBounds;
                var leftartwork = omtrekartwork[0];
                var topartwork = omtrekartwork[1];
                var rightartwork = omtrekartwork[2];
                var bottomartwork = omtrekartwork[3];
                var origin = doc.rulerOrigin;
                var leftpage    = -origin[0];
                var toppage    = -origin[1] + doc.height;
                var rightpage    = -origin[0] + doc.width;
                var bottompage    = -origin[1];
                var centerxpage    = -origin[0] + doc.width/2;
                var centerypage    = -origin[1] + doc.height/2;
                var bleedleft = leftpage - leftartwork;
                var bleedright = rightartwork - rightpage;
                var bleedtop = topartwork - toppage;
                var bleedbottom = bottompage - bottomartwork;
                var breedteartwork = rightpage - leftpage;
                var hoogteartwork = toppage - bottompage;
                if (bleedleft <= 0 && bleedright <= 0 && bleedtop <= 0 && bleedbottom <=0){
                        var artLayer = doc.layers['BB'].groupItems.add();
                        targetDocument.layers['BB'].preview = false;
                        var rect = artLayer.pathItems.rectangle ((toppage + (20*omf)),(leftpage - (20*omf)), (breedteartwork + (40*omf)), (hoogteartwork + (40*omf)));
                        rect.filled = false;
                        rect.stroked = false;
                } else {
                        if    (bleedleft >= bleedright){
                            var bleedx = bleedleft + (20*omf);
                        } else {
                            var bleedx = bleedright + (20*omf);
                        if    (bleedbottom >= bleedtop){
                            var bleedy = bleedbottom + (20*omf);
                        } else {
                            var bleedy = bleedtop + (20*omf);
                        var artLayer = doc.layers['BB'].groupItems.add();
                        targetDocument.layers['BB'].preview = false;
                        var rect = artLayer.pathItems.rectangle ((toppage + bleedy),(leftpage - bleedx), (breedteartwork + (2*bleedx)), (hoogteartwork + (2*bleedy)));
                        rect.filled = false;
                        rect.stroked = false;
    function getBounds(obj) {
        var vbounds = new Array();
        if( obj.typename == 'TextFrame' ) {
            objcopy=obj.duplicate().createOutline();
            vbounds = objcopy.visibleBounds;
            objcopy.remove();
        else if( (obj.typename == 'GroupItem') && !obj.clipped ) {
            vbounds = getBounds(obj.pageItems[0]);
            for( n=1; n<obj.pageItems.length; n++  ) {
                vgb = getBounds(obj.pageItems[n]);
                if( vbounds[0] > vgb[0] ) vbounds[0] = vgb[0];
                if( vbounds[1] < vgb[1] ) vbounds[1] = vgb[1];
                if( vbounds[2] < vgb[2] ) vbounds[2] = vgb[2];
                if( vbounds[3] > vgb[3] ) vbounds[3] = vgb[3];
        else if( (obj.typename == 'GroupItem') && obj.clipped && (obj.pageItems.length > 1) ) {
            vbounds = getBounds(obj.pageItems[0]);
            cvgb = getBounds(obj.pageItems[1]);
            objleft = cvgb[0];
            objtop = cvgb[1];
            objright = cvgb[2];
            objbottom = cvgb[3];
            obj.pageItems[0].stroked ? so = 0 : so = 1;
            for( n=so; n<obj.pageItems.length; n++ ) {
                cvgb = getBounds(obj.pageItems[n]);
                if( objleft > cvgb[0] ) objleft = cvgb[0];
                if( objtop < cvgb[1] ) objtop = cvgb[1];
                if( objright < (cvgb[2]) ) objright = cvgb[2];
                if( objbottom > (cvgb[3]) ) objbottom = cvgb[3];
            if( vbounds[0] < objleft ) vbounds[0] = objleft;
            if( vbounds[1] > objtop ) vbounds[1] = objtop;
            if( vbounds[2] > objright ) vbounds[2] = objright;
            if( vbounds[3] < objbottom ) vbounds[3] = objbottom;
        else {
            vbounds = obj.visibleBounds;
        return vbounds;
    function getPosition(obj) {
        var b = new Array();
        bnds = getBounds(obj);
        b['left']    = bnds[0];
        b['top']    = bnds[1];
        b['right']    = bnds[2];
        b['bottom']    = bnds[3];
        b['centerX']    = bnds[0] + (bnds[2]-bnds[0])/2;
        b['centerY']    = bnds[1] - (bnds[1]-bnds[3])/2;
        return b;
    function getDocPosition() {
        var b = new Array();
        doc = activeDocument;
        var origin = doc.rulerOrigin;
        b['left']    = -origin[0];
        b['top']    = -origin[1] + doc.height;
        b['right']    = -origin[0] + doc.width;
        b['bottom']    = -origin[1];
        b['centerX']    = -origin[0] + doc.width/2;
        b['centerY']    = -origin[1] + doc.height/2;
        return b;

  • How to control the number of rows selected from a sybase database table?

    Hi, JDBC guru,
    I'm working on project using Sybase 11.9.x database.We need to process a record in a table,first select it from the table,then do some computing,finally write it to a dbf file, if the above steps succeed,remove the original row in the table.Quite evidently, all these operation should be put into one transaction. But how can I select just a number of rows from the sybase database table?
    Any hints?
    Thank you in advance.
    Regards,
    Jusitne

    Statement stmt...
    stmt.setMaxRows(20);

  • How to make the obligate field in selection screen

    Hi ,
    In my report two radio buttons and two bloc selection screens are there.When we select the first radio button first screen will be editable second screen will be non-editable vice-versa.
    but the problem is in each selection screen one mandatory field is required  suppose if i give the one field obligatory in first block screen it is not allowing the second readout please help me regarding this how i will make the mandatory field in both screens.
    Thanks,
    Harinath

    Hi...
    Dont Declare your field as OBLIGATORY.
    Instead perform the validation in AT SELECTION-SCREEN event. But validation should be only when Particular Radiobutton is selected.
    And Generate only Error Message (Type E).
    Try this code:
    AT SELECTION-SCREEN on <yOUR mandatory field>.
       IF PA_UPD = 'X'.
             IF <YOUR MANDATORY FIELD>  IS INITIAL.
                  Message 'Entry is must in this field' type 'E'.
             ENDIF.
       ENDIF.
    AT SELECTION-SCREEN OUTPUT.
    IF pa_udp = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'ABC'. "#CCE
    screen-active = 1.
    ELSEIF screen-group1 = 'DEF'.
    screen-input = 0.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ELSEIF pa_rep = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'ABC'. "#CCE
    screen-input = 0.
    ELSEIF screen-group1 = 'DEF'.
    screen-active = 1.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ENDIF.
    <b>Reward if Helpful</b>

  • How to make checkbox to be pre-selected in ALV

    Hi all!
    I`m creating ALV report and I want to create checkbox in the first column of the row. So I have a field SEL(1) in my structure and I`ve made the fieldcat:
    gs_fcat-col_pos = 5.
      gs_fcat-coltext = 'Check'.
      gs_fcat-fieldname = 'SEL'.
      gs_fcat-tabname = 'GT_TREE9001'.
      gs_fcat-outputlen = 10.
      gs_fcat-checkbox = 'X'.
      gs_fcat-edit = 'X'.
    That works, checkbox is displayed.
    But now I need to make all the checkboxes to be checked for the first start of my program.
    I mean when user executes my report all the checkboxes must be checked by default.
    I have tried to do following:
    loop at gt_tree9001.
    gs_tree9001-sel = 'X'.
    modify gt_tree9001 from gs_tree9001.
    endloop.
    But it doesnt work, I now see checkbox and mark 'X' near but not the checked ckeckbox.
    Any help appreciated!

    Solved.
    My final code:
    data: lv_tree_size TYPE i,
                ls_layout_item TYPE lvc_s_laci,
                lt_layout_item TYPE lvc_t_laci,
                lv_ind TYPE LVC_INDEX.
          CLEAR ls_layout_item.
          ls_layout_item-fieldname = 'SEL'.
          ls_layout_item-class = cl_gui_column_tree=>item_class_checkbox.
          ls_layout_item-editable = 'X'.
          ls_layout_item-u_class = 'X'.
          ls_layout_item-u_editable = 'X'.
          ls_layout_item-u_chosen = 'X'.
          ls_layout_item-chosen = 'X'.
          append ls_layout_item to lt_layout_item.
    call method g_tree9001->set_table_for_first_display
          EXPORTING
            i_save              = 'A'
            is_variant          = ls_variant
          CHANGING
            it_sort             = gt_sort9001
            it_outtab           = gt_tree9001
            it_fieldcatalog     = gt_treefcat9001.
    DESCRIBE TABLE gt_tree9001 LINES lv_tree_size.
    DO lv_tree_size TIMES.
            CALL METHOD G_TREE9001->CHANGE_LAYOUT
              EXPORTING
                I_OUTTAB_INDEX = sy-index
                IT_ITEM_LAYOUT = lt_layout_item                .
    ENDDO.
    The main trick is in u_class, u_editable, u_chosen. These params say that layout should be changed. Only this way it will work.
    And some helpful links:
    ALV tree get selected checkbox
    Checkbox ALV Tree CL_GUI_ALV_TREE
    ALV TREE-Checkbox
    CL_GUI_ALV_TREE and Checkboxes
    Report BCALV_TREE_ITEMLAYOUT is also very helpful.

  • How do i keep my table row selected when i come back to the same page?

    I have have the following issue.
    I have a table with many rows. I select one row and click the button which takes me to another page. From that page when i click the back button which takes me back to previous page but the problem is that the row is no longer selected. How would i fix this problem?
    Any idea, suggestion or sample code will be appreciated.
    Thanks
    Nahman

    Here you go..
    1. To Get the selected Rows:
      DATA: TV          TYPE REF TO CL_HTMLB_TABLEVIEW,
             LT_FORMS TYPE TIHTTPNVP,
            TABLE_EVENT TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
        tv ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
                                          name    = 'tableView'
                                          id      = 'tvX' ).
        IF tv IS NOT INITIAL.
          table_event = tv->data.
          clear selectedRowIndexTable.
          selectedRowIndexTable = table_event->PREVSELECTEDROWINDEXTABLE.
          if table_event->event_type eq CL_HTMLB_EVENT_TABLEVIEW=>CO_ROW_SELECTION.
            read table selectedRowIndexTable with key table_line = table_event->ROW_INDEX
              transporting no fields.
            if sy-subrc eq 0.
              delete selectedRowIndexTable index sy-tabix.
            else.
              field-symbols <i> type i.
              append initial line to selectedRowIndexTable assigning <i>.
              <i> = table_event->ROW_INDEX.
            endif.
          endif.
        ENDIF.
      ENDIF.
    <b>Page attribute:</b>
    selectedRowIndexTable     TYPE     INT4_TABLE
    2. To store the selected row index into Server side cookie...
          CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>SET_SERVER_COOKIE
            EXPORTING
              NAME                  = 'select_row'
              APPLICATION_NAME      = 'NONE'
              APPLICATION_NAMESPACE = 'NONE'
              USERNAME              = SY-UNAME
              SESSION_ID            = 'NONE'
              DATA_VALUE            = selectedRowIndexTable
              DATA_NAME             = 'sbsp'
              EXPIRY_TIME_REL       = 3600.
    3. Get the value from Server side cookie..
          CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>GET_SERVER_COOKIE
            EXPORTING
              NAME                  = 'select_row'
              APPLICATION_NAME      = 'NONE'
              APPLICATION_NAMESPACE = 'NONE'
              USERNAME              = SY-UNAME
              SESSION_ID            = 'NONE'
              DATA_NAME             = 'sbsp'
            CHANGING
              DATA_VALUE            = selectedRowIndexTable.
    Hope this will help you...
    <b>* Reward each useful answer</b>
    Raja T

Maybe you are looking for