UnoControlGrid Numeric Column not sorting

I’ve developed a Lo (6.2) calc dialog containing multiple controls along with 3 dynamic grid controls. All string columns sort when the column header is clicked. However, one column of numbers does not accept a click on the header. If I use cStr(number) to insert into the column it will sort, but obviously the numeric value is not considered. Is there an attribute or option to solve this problem? Thanks.

Part deux - Thanks for the hint Ratslinger. I’ve included a short excerpt of the application. Additionally, I’ve discovered the column sort on the numeric column only failed when one of the values was less than 128. In the attached file if you run macro “Main” and click on the “Number” column in the grid, it will not sort. However, change the 127 value to 128 in the spreadsheet cell C1, and run the macro again, the column will sort. I went through a number of iterations and found this phenomenon. What significance can 128 have in determining whether a numeric column will sort in the grid? Thanks again.Coinexamp.ods

Best if you would post a sample file.

Please see Part deux

@awm119 Initial reaction is a bug. No problem if all 127 or lower or if all 128 or higher. Year & number are same.

My past experience with grid controls is to create dialog entirely from code. Will continue to try a few different options but will take time. Will post if any new discovery.

I did not see a problem using cStr(oRangeData(i) (2)) for the problem field. Seems to sort fine unless you have other insight.

Thanks again Ratslinger for the quick response.
Thought of cStr also, but obviously it sorts alphabetically vs numeric values.
After some more trial and error, it really gets strange. I found that the sort succeeds as long as the first cell (C2) is > 127. The lower values in any other cell do not impact the sort if the first cell is > 127. For my issue I can work around this, but it appears to be a bug.
If you don’t mind can you explain your experience “with grid controls is to create dialog entirely from code”? This is my first endeavor with LO basic and dialogs. Long time excel / vba, among other languages, experience. I didn’t locate any other method for creating grid controls, and would appreciate a nudge toward alternatives. Thanks again.

Sorry, still don’t see the sort problem eve when I place alpha char in column.

To be clear, it is not a different method to create controls; rather it is creating the entire dialog & controls within from code. In other not using the graphical interface you have used. With this method, I can create a non-modal dialog which is why I specifically designed it that way.

A crude very early sample of mine can be found here → Looking to create grid (not table) control on Base form.

Although a Base sample, you don’t need to run Base. Start the file and access the macros. Macros can be copied & used in a Calc file for demo purposes. Please excuse the code. If was first attempt at a grid.

Cool, I see non-modal form. I made mine modal by design. On the complete application, I have multiple combo boxes, images, text boxes and buttons on form, and didn’t want data changes in cells while text boxes, etc didn’t get updated on form. I also have three dynamically created grids which change content based on combo-box or button selections. One grid is actually a pop-up like list of range data based on a selected button.
In any case the cStr problem is that 200 sorts higher than 1401, while numerically it is less than 1401.
Good dialog. My first time on this forum and you’ve made it a pleasant experience…Thanks again

Yeah, certainly did not look close enough at sort. Will look at entire situation more a bit later. Will post any result.
Have also done non-modal dialogs using Python. Take care - it is a dialog not a non-modal form.