Grid ExecuteQuery
Massimiliano Luppis
I have a little problem with the ExecuteQuery method of the Grid object:I use a SELECT query to populate a Grid with some rows from Journal Entry; the user can select one row double clicking the Grid and then several operations are executed on the selected row.
The problem is this: I cannot know in advance if the input parameters will produce some rows or none; for instance, if the user selected a date range that contains no Journal row the Grid is empty (or it seems so).
But what really happens is that the Grid ALWAYS contains one row, also an empty one; so if the Grid appears empty and the user double click the first row, the form catch this event and the code executes as some useful row was selected.
Testing the Rows.Count is not useful, since it return always a number greater than zero, both in the case there are rows or the Grid contains only the empty one.
Is there a trick to know if the ExecuteQuery returns zero rows ?
Thank for all support.
Max
Massimiliano Luppis
Another question on the same issue:I could solve the problem using a RecordSet object to execute my query, so I always know if it returns some rows or nothing.
But how do I populate the Grid with the RecordSet returned by the query ?
Marco Schweighauser
Hellothe fastest way would be to execute the query twice, since manually fill the grid is much slower since executing a second query.
Anyway if you want to try you can access the DataTable of the Grid and add manually the Columns and Rows.
Regards,
Marco
Massimiliano Luppis
Hi Marco,do you mean one query to fill the Grid and one query to know if the query returns some rows ?
Well this could be a way, I can run the first query to populate the recordset and if there is one or more rows returned I can run again the same query to populate the Grid.
But do you know why there is always a row, also an empty one, in the Grid ?
Marco Schweighauser
This empty row stuff is a "feature" of SAP B1 - no reason but it is there ;)Massimiliano Luppis
Thank you Marco for your replies.Just for fun I tried to add columns and rows manually but it is a very slow process, so the best way to populate a Grid is surely the ExecuteQuery method.
And by the way, the empty row is always there; every time you create a Grid it magically appears, no matter how you populate the Grid.
However with the two step method I can manage it.
Best regards
Max
0
Please sign in to leave a comment.
Comments
0 comments