cancel
Showing results for 
Search instead for 
Did you mean: 

How to get selected Row/Cell value in i5Grid

shaji_chandran
Participant
0 Kudos

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 Chandran

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shaji,

you can use the following JS functions which are available in Script Assistant.

.

In the following Format.. in Java script

Grid.getGridObject().getSelectedCellColumn()

Grid.getGridObject().getSelectedCellRow()

...

you can get selected Cell value like this.

var col_no=Grid.getGridObject().getSelectedCellColumn();

    alert(Grid.getGridObject().getSelectedCellValue(col_no));

Regards,

Sriram

shaji_chandran
Participant
0 Kudos

Hi Sriram,

Thanks for your reply. I will try this.

BTW where did you get the above screenshot? Is it from MII workbench?

Thanks

Shaji

Former Member
0 Kudos

Yes Shaji,

This is how you can open script Assistant.

You have to drag that Line highlighted in Green color, upwards. Then you ll be able to see it

Regards,

Sriram

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Shaji,

You can find all the getter and setter methods for i5Grid here:

i5Grid Object Methods - i5Grid - SAP Library

Regards,

Rohit Negi.

shaji_chandran
Participant
0 Kudos


Thanks Rohit.

Is there any issue with setCellValue method? I am able to set only for the first time. Second time it is not setting the value

Regards

Shaji

Former Member
0 Kudos

Hi Shaji,

I tried to setCellValue twice and it worked. I tried in 14.0 SP05.

Regards,

Sriram

shaji_chandran
Participant
0 Kudos

Sriram,

Can you please share the code?

Thanks

Shaji

Former Member
0 Kudos

Hi 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

shaji_chandran
Participant
0 Kudos

Sriram,

Thanks for sharing the code. Here you are changing the value of same cell again. Let me explain my scenario. I have got 2 i5Grid objects and want to add the items from object to another.

I will select an item from the one grid and want to add the same item to other grid at onlick event of a button (Add button).

What happens for me is that, it will add only for the first time. Second time when I select an item and follow the same process (click on add button) it doesn't add.

Any help on this very much appreciated

Thanks

Shaji

Former Member
0 Kudos

Hi Shaji,

While adding the Selected Item to second grid, Make sure that row index should be incremented before using the method

setCellValue(int,int,string)

while adding a new item, or else it will simply over write the existing one.

I tried the scenario which you told . Is it the below one which you were asking about ?

Regards,

Sriram

shaji_chandran
Participant
0 Kudos

Sriram,

Thanks for you effort again.

Yes I am taking care of rowIndex. I just tried to hard code some values to add the grid. The below code is only adding first item to the grid.

selectedTagListGridObj.setCellValue(1,1,"one"); --> This line works as expected

selectedTagListGridObj.setCellValue(2,1,"two");

selectedTagListGridObj.setCellValue(3,1,"three");

Thanks

Shaji

Former Member
0 Kudos

Hi Shaji,

I tried this.

Grid_Obj.setCellValue(1,1,"Set");

    Grid_Obj.setCellValue(2,1,"SetAgain");

    Grid_Obj.setCellValue(3,1,"Set 3rd time");

This is the output.

I did this in 14.0 SP05. May be the issue lies with only SP04.

Regards,

Sriram

shaji_chandran
Participant
0 Kudos

Yes Sriram.

I really appreciate your help/effort for this query.

Looking for an oppurtunity to help you back:)

Thanks

Shaji