Problems attempting to display data with jGridView lazarus / 43-Android ---------------------------------------------------------------------- maurobio · 2023-05-25 20:47 Dear ALL, I have been struggling to achieve in an Android app one of the most fundamental tasks in any user-oriented software (be it for mobile or desktop devices), namely, displaying data to the user in spreadsheet- like tabular form (like offered by the Delphi/Lazarus StringGrid and DBGrid controls). I of course started from the basics: I attempted to modify the AppSqliteDemo3 included with LAMW to perform this task. I try to more or less replicate the nice (but unfortunately incomplete, because the author did not made available all the code) example here: https://forum.lazarus.freepascal.org/index.php?topic=39290.0 I added two jGridViews, The app compiles and runs, but (as always!) there seems to be a problem with finding the correct layout of the two grids (the directions provided by the author of the linked example do not seem clear enough to me): the grid that should show the data is not displayed, and the grid which which should display the headers (column names) appears too large and the names of the columns do not appear well. Could someone give me a hand? I attach my tentative example (for what it is worth). Thanks in advance!!! PS As an aside, I have two questions: I noticed that LAMW includes a jDBGridView which presumably should behave like Delphi/Lazarus DBGrid, but I could not run the demo; it there other (simple!) examples of this component? Is there any limits (in performance, I mean) to the size and number of records of a SQLite database in Android? My real database has 12,000 (yes, twelve thousands) records and about 1 Mb in size. When I attempted to run the AppSqliteDemo3 with my database, instead of the small one provided with the demo, the app froze and then crashed. ---------------------------------------------------------------------- jmpessoa · 2023-05-26 05:10 From your project ".lfm" Quoteobject jGridView1: jGridView     PosRelativeToAnchor = []     PosRelativeToParent = [rpCenterInParent]     LayoutParamWidth = lpFiveSixthOfParent     LayoutParamHeight = lp48px     LayoutParamHeight = lpOneEighthOfParent Quoteobject jGridView2: jGridView     PosRelativeToAnchor = []     PosRelativeToParent = [rpCenterInParent]     LayoutParamWidth = lpFiveSixthOfParent    LayoutParamHeight = lpOneEighthOfParent What?  Quote object Button1: jButton     PosRelativeToAnchor = [raBelow]              PosRelativeToParent = [rpBottom]     LayoutParamWidth = lpOneThirdOfParent     LayoutParamHeight = lpWrapContent What? The start is here: https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/docs/GU IDesignWYSIWYG.md https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/docs/Ap pHelloWorld.md ---------------------------------------------------------------------- maurobio · 2023-05-26 10:00 Hi, @jmpessoa! Unfortunately, I could not understand your answer. Other than showing me what I already knew - that in my frantic attempts at achieving what my not be possible, I just messed up with the layout parameters of the grid - it has not been much useful. What I need is just a simple - and fully working - example of a SQLite database being loaded into a jViewGrid, The AppSQLiteDemo3 which comes with LAMW would be in fact a good start, by simply substituting a grid for the display of each record using ShowMessage(). Can it be done? If so, how? But in the specific case of my "real" app, it turns out that even the fancy details of layout may become irrelevant if there is no answer to my pressing question, namely: can a SQLite database with 12,000 records be realistically loaded and displayed in a jViewGrid, jListView, whatever? Because if this is not possible, than there is no sense in wasting time with it! Best regards, ---------------------------------------------------------------------- TRon · 2023-05-26 10:31 Quote from: maurobio on May 26, 2023, 12:00:52 pmUnfortunately, I could not understand your answer. I do not have any knowledge on the topic at hand but even I am able to see that the positioning of the controls (grids) is exactly the same. Thus it is no wonder you are only be able to see one ? ---------------------------------------------------------------------- maurobio · 2023-05-26 10:45 Hi, @TRon! As I wrote in my previous reply to @jmpessoa, I know that the layout is messy, but that is no longer my main concern! Layouts can be worked out sooner or later - but they are completely irrelevant if a large database cannot be realistically handled by jGridView! Best regards, ---------------------------------------------------------------------- maurobio · 2023-05-26 10:52 Dear ALL, I just got the code below working: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure SplitString(Delimiter: char; Str: string; ListOfStrings: TStrings);begin  ListOfStrings.Clear;  ListOfStrings.Delimiter := Delimiter;  ListOfStrings.StrictDelimiter := True;  ListOfStrings.DelimitedText := Str;end; procedure TAndroidModule1.PrepareGrid1;var  rows, values: TStringList;  i, j: integer;begin  if FTableName <> '' then  begin    ShowMessage('Start loading table...');    jGridView1.Clear;    jGridView1.ColCount := 8;    rows := TStringList.Create;    values := TStringList.Create;    rows.StrictDelimiter := True;    rows.Delimiter := jSqliteDataAccess1.RowDelimiter;    rows.DelimitedText := jSqliteDataAccess1.Select('SELECT * FROM ' + FTableName);    for i := 0 to rows.Count - 1 do    begin      jGridView1.AddRow(i);      //ShowMessage(rows.Strings[i]); // This is in the original AppSqliteDemo3      SplitString('|', rows.Strings[i], values); // See the declaration of SplitString above      for j := 0 to values.Count - 1 do        jGridView1.Cells[j, i] := values[j];    end;    rows.Free;    values.Free;  end;end; As I said, this code works - but a delay in filling the grid is perceptible even if the sample database has only four columns and seven records. I very much doubt that a twelve thousand records database can be realistically displayed in this way. With best regards, ---------------------------------------------------------------------- TRon · 2023-05-26 11:03 I can not really help you there as I do not have any knowledge on the Android topic (and its used classes). Having said that, I do notice a couple of things that are related to generic programming wrt the use of stringlists and databases. - A grid is not really suited for storing lots of content unless there is a so called virtual mode (I do not know if jgridview has one). - You seem to load the complete database into a stringlist in one go. Normally you would make a select statement and then use .next method to advance to the next record. That way you can access each field individually (instead of the need to abuse a stringlist and the need for a splitstring function). - If there is a DB version/variant of the jgridview then that would be better suited to display data from a database (that is why Database components/variants exist in the first place) - Usually a stringlist and a grid have methods to tell the OS that it begins updating and ends updating their content, so that visual updates (and or other events) are not performed when adding data. That saves a considerable amount of time. ---------------------------------------------------------------------- maurobio · 2023-05-26 11:14 Hi, @TRon! Many of the points you raised are not really relevant to Android development. For example, there is no TStringGrid in LAMW (jGridView is its replacement instead). There is a DB-oriented version of jGridView in LAMW, but I could not run its demo, therefore resorted to jGridView. Other than that, I simply followed the demos provided with LAMW to do my experiments (While I have some years of experience with Delphi/Lazarus under Windows/Linux, I am just starting in Android development, and it is very different at times). Best regards, ---------------------------------------------------------------------- TRon · 2023-05-26 11:57 Quote from: maurobio on May 26, 2023, 01:14:35 pmFor example, there is no TStringList in LAMW uhm ? Quote from: maurobio on May 26, 2023, 12:52:08 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...procedure TAndroidModule1.PrepareGrid1;var  rows, values: TStringList;...  QuoteThere is a DB-oriented version of jGridView in LAMW, but I could not run its demo, therefore resorted to jGridView. It would imho be a better option to investigate that route. QuoteI am just starting in Android development, and it is very different at times). I am fully aware that it is not exactly the same, and I do know nothing at all about it  . However, As I investigated the class (https://github.com/jmpessoa/laza ndroidmodulewizard/blob/master/android_bridges/gridview.pas ) I did notice you can set a rowcount in one go instead of adding a row one by one. Have you tried that ? (and then later set the items instead). No matter the difference, I am still convinced that you should not have to first load the data from the DB into a stringlist. ---------------------------------------------------------------------- maurobio · 2023-05-26 12:04 @Hi, TRon, Sorry, I mean "there is no TStringGrid" on LAMW, of course!