cancel
Showing results for 
Search instead for 
Did you mean: 

i5Grid getRowCount() is not working on page loading

0 Kudos
637

when the page loads am trying to get the number of rows in the i5Grid but am not sure why it shows 0 row count. The only time where I could see the row count is when the i5Grid is selected.

Below is the sample code:

var grid_c0c0 = new com.sap.xmii.grid.init.i5Grid("grid template path","query templ path",true);
grid_c0c0.registerCreationEventHandler(ceController.addObject("c0c0",grid_c0c0));
grid_c0c0.draw("gridc0c0");
alert("initial"+grid_c0c0.getGridObject().getRowCount());

I couldn't figure out what is the issue. Any help would be Appreciated.

Thanks

Sap

View Entire Topic
former_member185280
Active Contributor

I think some async goes on and you may be trying to use parts of the grid object before they get completely instantiated. Try triggering your logic with the FirstUpdate or Update events. There won't be any rows or data in there anyway until those are fired.

0 Kudos

Here is the code sample which I tried with first update event and I still get the same error. Am not sure if anything is wrong with my code.

<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Test Page---</TITLE>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<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">
</SCRIPT>
</head>
<SCRIPT type="text/javascript">
function checkValue(){
var count = i5Grid_Applet.getGridObject().getRowCount();
alert(count);
}

var i5Grid_Applet = new com.sap.xmii.grid.init.i5Grid("Test/test_i5grid","Test/test_qry15");
i5Grid_Applet.setGridWidth("640px");
i5Grid_Applet.setGridHeight("400px");
i5Grid_Applet.registerFirstUpdateEventHandler(checkValue);
i5Grid_Applet.draw("myDiv");
</script>
<body>
<div id="myDiv"></div>
</body>
</HTML>

agentry_src
Active Contributor
0 Kudos

Hi Sap Ram,

Please mark Christian's Answer as correct so others will know the solution which applied to the problem you encountered. You can also close the question after that.

Regards, Mike