Ask Your Question

# Create data grid in dialog

I have seen answers (all same) in similar questions here and here and here. But is there a "simple" way to pass a BASE table or any other recordset type (ex. from an SQL query) to the Grid "widget" mentioned there?

We can extract all records from a table or SQL query and append them as rows, but this will have performance penalties already resolved by the grid "widget" included in BASE forms. The grid in BASE forms does all the stuff by fetching more rows when the user scrolls down or by changing the rows when a filter is applied etc. etc. so there is no need to "reinvent the wheel".

A simple filter can be applied in code by adding a text entry in the dialog with a "listener".

The problem exists because (as far as I know) there is no way to create a modal form, from which the user can select a single value in a way more "friendly" than a dropdown list.

Slightly modifying Ratslinger's GridDialog.odb example (from above mentioned link) I created a dialog that gets a selection ( DialogGridDemo3.odb).

But still this cannot be used to automatically receive data from recordset in a usable way such as creating a filter while the dialog runs for example by adding a checkbox that will filter results showing -or not- only latest year.

1. The only distinction between the idea of "normal window" and a dialog is that dialogs wait (in code) for user interaction and may return a value based on user's answer. Normal windows are just "presented" to user without "waiting" (in code).
2. OpenOffice (thus I assume LibreOffice also) is based on MVC architectural design which means data awareness of the control depends on controller, not the control itself.
3. There is definitely a LibreOffice service (simple or complicated, but I do not know which is) that implements the data awareness of the grid inside the Writer Documents that are used as "forms" ("form" a.k.a window, not "form" as the MainForm inside that Writer Document) in the .odb files. I am not sure if this service uses the same grid control (but I assume it is). If this is not the case, which is the service (and the accompanied control) that gets and presents the data in a grid in the Writer Documents that are used as .odb "forms"?

So the "final" question is: Is there a way to provide a "data provider" to such a grid embedded in a dialog?

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted

The answer is no. The grid control was never intended to be data aware.

Edit 2018-05-17:

@Xoristzatziki When modifying your question please note the edited parts. Not doing so can make one who has already provided an answer based upon the original question look foolish!

Original last part of question:

But still this cannot be used to automatically receive data from recordset in a usable way such as creating a filter while the dialog runs for example by adding a checkbox that will filter results showing -or not- only latest year.

So the "final" question is: Is there a "simple" way to provide a "data provider" to such a grid embedded in a dialog?

New last part:

But still this cannot be used to automatically receive data from recordset in a usable way such as creating a filter while the dialog runs for example by adding a checkbox that will filter results showing -or not- only latest year.

1. The only distinction between the idea of "normal window" and a dialog is that dialogs wait (in code) for user interaction and may return a value based on user's answer. Normal windows are just "presented" to user without "waiting" (in code).
2. OpenOffice (thus I assume LibreOffice also) is based on MVC architectural design which means data awareness of the control depends on controller, not the control itself.
3. There is definitely a LibreOffice service (simple or complicated, but I do not know which is) that implements the data awareness of the grid inside the Writer Documents that are used as "forms" ("form" a.k.a window, not "form" as the MainForm inside that Writer Document) in the .odb files. I am not sure if this service uses the same grid control (but I assume it is). If this is not the case, which is the service (and the accompanied control) that gets and presents the data in a grid in the Writer Documents that are used as .odb "forms"?

So the "final" question is: Is there a way to provide a "data provider" to such a grid embedded in a dialog?

Now regarding this new information.

1 - The dialog (actually a container) has no data source available to it. Therefore as constructed, the controls contained within have no method to connect to database information.

2 - If a control was not designed to interact with a data source (read database) it can only do so if you either write your own code to do it or design your control to do so. Another example here is a label control. Not data aware (still follows MVC).

3 - The object you refer to in Writer is a 'Table' which is more akin to a mini spreadsheet. This is NOT the same as the grid control used in my example. I have not tried to insert a table into a dialog. Tables can be inserted into forms (not the same as table grid control) but looking at this several years ago did not find much use ...

more

## Comments

Sorry, but I am not asking if grid control «per se» is able, but if there is a "simple" way to provide a "data provider" to that (not intended to be data aware) control. This is definitely done in BASE forms.

( 2018-05-15 06:39:45 +0100 )edit

No. Dialogs and Forms are quite different in that there is no data connection or data aware controls in a dialog. Since the grid control can only be used in a dialog (no one has claimed otherwise in years) it is not data aware in any sense. As seen in my example, the only way to get data to the grid (or any other control in a dialog) is passed by code.

( 2018-05-15 07:14:10 +0100 )edit

Even with a data provider if the control is NOT data aware, the provider is senseless. you would still have to move the data from the provider to the control.

( 2018-05-15 07:17:51 +0100 )edit

Sorry for the type of modifications. My intend was to commenting, but the space is scarce. And sorry for mentioning you, thus personalizing the question to your code (hence your answers are about your intentions and tries). I do not want to be the first, I just hate reinventing the wheel. Also a... "table" is as good as a grid. Our dialog-comments here probably lead to the final "is possible using LO BASIC code to add a data source to a container".

( 2018-05-18 04:40:37 +0100 )edit

Not sure you understood my text. Mentioning me or my code is not a problem. Changing your question without noting the change (as I placed Edit in my answer) is the problem for myself or anyone else this is done to. The original question was answered but if the original question is modified the answer seems like the person had no idea what the question was.

I simply ask that when modifying a question, just note the edited section.

( 2018-05-18 06:12:39 +0100 )edit

Now, forgetting the past, I understand what you have been trying to do here but certain things elude me. Why do you not want to select from a table grid on a form? This appears to be what you are aiming for or is it something else?

( 2018-05-18 06:15:27 +0100 )edit

I think this is obvious. Ex. when in a form that adds a product, that product can have many specifications which are best added by using a modal form that shows these specifications. User can't add producer or place of origin, or many other fields neither from a drop down list nor from a grid in the form, neither by opening a non modal form searching and copying the id. Can't do this even for the most primitive like a VAT category (may have comments).

( 2018-05-19 05:13:14 +0100 )edit

## Stats

Asked: 2018-05-13 09:11:19 +0100

Seen: 327 times

Last updated: May 17 '18