Grid Control display issues

Hello everybody,

Calc - Libreoffice version 7.2.4.1
Windows 10

I am having a couple of display issues with displaying of a control grid which is located on a dialog form (not created programatically).

Problem #1:
I have created this control grid to use only the vertical scroll bar. However, when the form and the grid control within displays (columns created, rows with data already populated) the vertical scroll bar does not show up, nor does the roller on the mouse work. What I need to do at that point is select one of the visible rows with my mouse, then using keyboard scroll down to at least the very first row which was not originally visible, and then go all the way back to the first row. At that point, the scroll bar shows up and the roller/wheel on the mouse is working perfectly.

Problem #2:
The data displayed in this grid control has 7 columns, and currently about 500+ rows of information. I have created a combo box with option of sorting the data by a particular column. When I choose my selection within the combo box, the data is updated in the control gird. However, it is not displayed until I move the roller/wheel on the mouse at least one notch.

I am completely at a loss here, and cannot seem to resolve either one of the issues. Tried the following:

With respect to the scroll bar not showing up:

  1. Tried adding it programatically during initialization
  2. Tried playing around with the size of the control grid window, within the form, to see if there is any predetermined recurring size that needs to be adhered to.

With respect to the displaying of the updated data:

  1. I looked through the variables and their values within the control and control.model objects of the grid control, but could not find anything there that would allow me to change the focus of the currently selected row. All those values seem to be set to read only. My intention was to set focus on line, for example, 11 (if let’s say 10 are only visible at once) and then set it back to the first one. I am not sure if it would work, but it would definitely be worth a shot.

Any help/suggestions would be greatly appreciated. Thank you in advance.

Hello,

With that amount of data (and growing?) do not understand why you are using a grid control. Although not stated what DB you are using, most allow the creation of a temporary table. This seems to be a better direction since you can then use a table control on a form and all the built in data controlling characteristics.
.
If you wish to proceed with the grid control, please provide a sample showing the issues faced.
.
Also not clear as to the last post about grid controls. You only stated you would try. No response if it resolved your issue. How are we to know when answering if we are of help when there is no mention either way?

@Ratslinger

To begin with, thank you @JohnSUN and Mr. @Lupp for all your time and help. What I should have stated in advance is that I am not a professional programmer, and I am learning all this completely on my own. Although I still do not comprehend all of the programming aspects completely, I love the challenge and I love to learn about all this.

My ultimate goal is to create means of better running my own company, and until now the idea was to build it on top of a spreadsheet. First I begun with Excel/VBA, then I have learned about Libreoffice and I immediately switched. Granted the learning curve with LO Basic is somewhat more difficult but the challenge is awesome. I just wish there would be more time in my day to go over in depth my Pitonyak’s work and all the other sources I have found so far. Yet even with these, I am still having problems understanding some aspects here and there.

Nevertheless, so far I did not touch any database. My rationale was that if spreadsheet is capable of holding over a million rows of data, and I am more familiar with Excel/Calc, I’ll stay with Calc and expand on it by applying dialog forms and scripts. Thus all the data is still sitting and being manipulated in a spreadsheet. In all honesty, aside from the aforementioned control grid issues everything else works absolutely fine. This is still work in progress, and a lot of features are missing, but so far so good. I truly understand that creating forms, queries and relationships in a database would definitely be quicker. Lupp already stated earlier that a database would definitely be a more appropriate tool. However, by going “the hard way” I feel I had an opportunity to learn more about semantics of programming. Which is also what I was after. Plus, I’m sure that creating such project in a database would come with its own array of issues to resolve. Therefore, even if I would have to transfer my spreadsheet data to a database, and continue that route, at least now I am this much more aware of how to code in LO Basic, which I’m sure will come in handy.

On the other hand, it seems rather odd that if a Calc spreadsheet is able to hold that much data, there are peripheral tools such as the control grids with such limitations, which are to assist in manipulation of that data.

I am attaching two files. One holds the data which I’m using, and the other one is the actual form. This is still very much work in progress, but this is where I got so far. For this to work, please do the following:

  • Keep them both in the same directory, and change “nameDir” module constant in Standard/DataManipulation folder to whatever directory you are using.
  • You can simply invoke subroutine “MaterialQuotationsMenuToggle” in Standard/Forms folder, to get access to my issue at hand.

Once again, thank you kindly for your help. Any criticism is truly welcome.

_WSL_Material.ods (58.0 KB)
Program.ods (26.3 KB)

Well, that kicked out an error right away. Seems that this may take a bit of time. Have something else currently taking precedence. Will look again later.

1 Like

What error did you get? When you replaced the path in that constant, did you add a backslash at the end?

Nope! In too much of a rush. Still, will look further later. No error currently.

Edit:

Last time I answered a question about a grid control in a GUI dialog, it turned out that much was not implemented (at least to my liking). All grid controls I use are completely from code (including the dialog itself).
May take just a bit of time (later though) to get you what may be needed. Initial look and the scroll bars don’t seem to be implemented.

1 Like

image Ratslinger
All grid controls I use are completely from code

Then I’ll code them in. I just thought that it would be less error prone to let Calc define them.

image Ratslinger
Initial look and the scroll bars don’t seem to be implemented.

No matter how many times I have switched the scroll bars option to either horizontal, vertical or both, and saved them they always defaulted to none, next time I have opened the file.

Just getting ready to go somewhere but looked at my Dialogs with grid controls and there are no scroll bar issues.

See my answer & COMMENTS here → Macro insert data into table control @dialog

Time flies…

Got this far (500 of same line but has the scroll bar):

Now trying to figure how to incorporate in your code. Kind of all over as far as what I need.
Again, problem with grid control in the GUI. Code seem to work much better.
Had it for tonight. Will look again tomorrow.

Thank you so much. Myself, on the other hand, am learning how to create forms and controls programmatically. I got both, now I’m trying to establish listeners and handlers.

I’ll include in the sample when I get there.

Hello
Thanks for answer of my needs (almost) from this link: Apache OpenOffice Community Forum - [Solved] Horizontal large table inside a dialog - (View topic)
Now i miss a way of after show data in the db grid locate( Column, KeyData etc…) a certain among all others; or some kind of Go To Line. Are there some built in features or do i have to build all it my self?
I mean, how to Look fo data in a Grid Collumn
But also a way of “clearing data in the grid” before reaload new data

You need to build it yourself - nothing built in.

As in the past you have not explained what you are doing so have no direct answer for this. Typically when a grid is displayed in a dialog it is filled when the dialog is called to be displayed.

Solvede:
oDataModel = oDlg.getControl(“tab_g1”).model.GridDataModel
’ Limpa todos os dados == ZAP in memory
oDataModel.removeAllRows()

Now i’m trying this:
oRowSelection = createUnoService(“com.sun.star.awt.grid.XGridRowSelection”)
oDlg.addControl(“tab_g1”, oRowSelection )

’ Later with a commadn button my listner
dim mygrid1 As Object
myGrid1 = oDlg.getControl(“tab_g1”)
’
myGrid1.SelectAllRows() ** Does nothing **
Can you help
best regards

@dosreis57
Please ask this and others as new question. You continue to bury questions in other posts which are barely related. It make it difficult for others to find. Will not answer buried questions anymore.


Edit:
Testing has this as a bug. Found the answer & tested OK:

oControl.Model.SelectionModel = com.sun.star.view.SelectionType.MULTI

Other functions work.
Only new and not buried questions please!

Hello,

Have what seems to work. Give it a try.

deleted bad version

Most changes in Forms->CreateGridControl

I state most as there where so many issues in integrating my working Dialog with your code as to not exactly remember what or where.

There may be other issues, but with your literal for the directory I needed to change, you can get that from the document itself. Its the file URL - strip off the file name.

@Ratslinger
Thank you very much for doing all this. I see there is an extensive amount of modifications which I need to go through and learn. Unfortunately, it is kicking me out at the following line:

Globalscope.BasicLibraries.LoadLibrary( “MRILib” )

I managed to learn how to create a Dialog form and insert a control button on it. I also created a listener and handler for that button, which successfully fires up. Although, there are tons of questions still unanswered. For instance, it is still extremely cumbersome for me to read the API reference. I’m still trying to determine where to find a list of listener prefixes. Or which which listeners associate with which controls. I’m attaching a file of what I have learned (by looking at other folks code samples mostly) so far in the last 24 hours. In all honesty, even though I will definitely thoroughly go through all the modifications which you have done, I am very grateful for the suggestion of actually creating those controls programmatically. It is definitely the way to go.

Program2.ods (9.8 KB)

Yeah was about to post a modified version. Also corrects a couple of other issues. There is also a mouse handler. Just double click anywhere on grid.

ProgramPost.ods (26.1 KB)
{2nd Corrected version - eliminates duplicate columns).

Edit:

Thanks for the reminder. Generate listener prefixes with code. See my post here → How to properly code a broadcaster and listener in LO Basic

Thank you once again! I need some time to digest through this now and let you know how it goes :slight_smile: