Recent

Author Topic: VirtualDbGrid Can i do some thing like that  (Read 17912 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
VirtualDbGrid Can i do some thing like that
« on: December 11, 2021, 08:00:30 pm »
Hi is possible with virtualgrid do some thing like that or virualdbtree

any idea great...

thanks...

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: VirtualDbGrid Can i do some thing like that
« Reply #1 on: December 11, 2021, 08:05:14 pm »
There's a ready-made component for it: https://github.com/adem0x/virtualdbtreeex, you can also find it on Online-Package-Manager. See https://forum.lazarus.freepascal.org/index.php/topic,55727.msg415912.html#msg415912 for a demo project.

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #2 on: December 11, 2021, 09:52:47 pm »
Ok  thanks i download package but when i compile send this error

VirtualTrees.pas(772,19) Error: No matching implementation for interface method "SetData(const tagFORMATETC;var TagSTGMEDIUM;LongBool):LongInt; StdCall;" found
I have lazarus 2.0.12 on windows



eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #3 on: December 11, 2021, 10:02:55 pm »
I had installed virtualtree from repository package on line , so i need to uninstall this and download form ccr repository  and install..

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: VirtualDbGrid Can i do some thing like that
« Reply #4 on: December 11, 2021, 10:58:36 pm »
Ok  thanks i download package but when i compile send this error

VirtualTrees.pas(772,19) Error: No matching implementation for interface method "SetData(const tagFORMATETC;var TagSTGMEDIUM;LongBool):LongInt; StdCall;" found
I have lazarus 2.0.12 on windows
I checked with Laz 2.0.12 on Win 11. It has a built-in VirtualTreeViews package (needed by the Online-Package-Manager). No problem to add VirtualDBTreeEx. Then I installed the VirtualTreeViews from OPM - again no compilation issue.

Did you try a clean recompilation of the IDE? "Tools" > "Configure Build Lazarus" > in the "Clean up" box, check "Clean all" and "Switch after building to automatically" > "Build".

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #5 on: December 12, 2021, 12:12:36 am »
Wow use a lot compenents i can find extcopy adn Exprtsuperform where i can find all of them...

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #6 on: December 12, 2021, 12:20:06 am »
All this components

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: VirtualDbGrid Can i do some thing like that
« Reply #7 on: December 12, 2021, 12:32:37 am »
If you don't know where you have these packages from you probably do not use them. Go to "Package" > "Install/Uninstall Packages". Find these packages in the left list, select them and click "Uninstall selection"; this way the packages are moved to the right list "Available for installation". Then "Save and rebuild IDE". This will rebuild the IDE without these components (but with the VirtualDBTree if you did not remove it).

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #8 on: December 12, 2021, 02:52:57 am »
DbDataFieldnames   := Category

Is only one field name  or Category, Type 

Headers we can define titles of columns but where we put field of table.....


sorry i don't can create the demo just i read the help files but are on french not English  or spanish


wp

  • Hero Member
  • *****
  • Posts: 11912
Re: VirtualDbGrid Can i do some thing like that
« Reply #9 on: December 12, 2021, 12:44:34 pm »
I extended the sample project referred to above: Moved all (?) the settings from the object inspector into the code so that it is easier for you to see what is important. Added lots of comments. Added more columns to see how they can be displayed.

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #10 on: December 12, 2021, 09:42:29 pm »
Ok Thanks Now i see what i need to config to get work for me.....

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #11 on: December 13, 2021, 04:30:47 pm »
After work with your example witch help me great, i made some change on my tables for get work like your example i have some questions...

Look attachs screen in your example you create field text1 and write 0,1  as reference of record is top node but sql table take values from table we have de information there, so i need to change information of node to display information as must be from table....

or i have to create a virtual table from sql database and write the information on virtual table as must be show...

you can see all groups has same value in listviewfield....but you open  node you see information is litte different in my case i use category and parentid field...

 

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #12 on: December 14, 2021, 03:52:35 pm »
Sorry for  topic i still testing dbtreeex i create a new table with buffdata on dbgrid show me information but dbtreeex  send me this error, could be trying to generate a sub levels on tree or what could be error....

 

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: VirtualDbGrid Can i do some thing like that
« Reply #13 on: December 14, 2021, 04:01:02 pm »
Which error? A SIGSEGV? Then probably no fieldname has been assigned to property ViewField - this is the field text to be displayed in the left-most column.

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: VirtualDbGrid Can i do some thing like that
« Reply #14 on: December 14, 2021, 04:11:46 pm »
Thanks for replay, yes is assigned viewlisfield here my code...

Code: Pascal  [Select][+][-]
  1. procedure TFormPartsTree.FormShow(Sender: TObject);
  2. Var RegAnt,Registers:Integer;
  3.     found:boolean;
  4. begin
  5.  // Define the dataset fields
  6.   BufDataset1.FieldDefs.Clear;
  7.   BufDataset1.FieldDefs.Add('cateid', ftInteger);
  8.   BufDataset1.FieldDefs.Add('itemID', ftInteger);
  9.   BufDataset1.FieldDefs.Add('category', ftString, 10);
  10.   BufDataset1.FieldDefs.Add('masterpno', ftString, 50);
  11.   BufDataset1.FieldDefs.Add('partnumber', ftString, 50);
  12.   BufDataset1.FieldDefs.Add('ItemName', ftString, 200);
  13.   BufDataset1.FieldDefs.Add('ItemDescription', ftString, 200);
  14.   BufDataset1.FieldDefs.Add('Type', ftString, 20);
  15.   BufDataset1.FieldDefs.Add('Rev', ftString, 20);
  16.   // Create the dataset
  17.   BufDataset1.CreateDataset;
  18.  
  19. //  BufDataset1CreateDataset;
  20. //   BufDataset1Open;
  21.  
  22.    osql:=DMSQL.SQLQParts.SQL.Text;
  23.    if(  DMSQL.SQLQParts.Active=true) then begin
  24.        DMSQL.SQLQParts.close;
  25.    end;
  26.  
  27. //   DMSQL.SQLQParts.SQL.Text:='select * from stockparts order by category' ;
  28. //   DMSQL.SQLQParts.open;
  29.  
  30. // Add from mysql table to dataset memory
  31.  
  32.    DMSQL.SQLQCate.Open;
  33. //   Registers:=0;
  34.    while( not DMSQL.SQLQCate.eof) do begin
  35.       BufDataset1.Append;
  36.       BufDataset1.FieldByName('cateid').AsInteger := DMSQL.SQLQCate.FieldByName('ID').AsInteger;
  37.       BufDataset1.FieldByName('itemid').AsInteger := 0;
  38.       BufDataset1.FieldByName('category').AsString := DMSQL.SQLQCate.FieldByName('cateid').AsString;
  39.       BufDataset1.Post;
  40.  
  41.       regAnt:= BufDataset1.RecNo;
  42.       DMSQL.SQLQParts.SQL.Text:='select * from stockparts where category=:pCateid' ;
  43.       DMSQL.SQLQParts.ParamByName('pcateid').AsString:= DMSQL.SQLQCate.FieldByName('cateid').AsString;
  44.       DMSQL.SQLQParts.open;
  45.       Registers:=0;
  46.       found:=false;
  47.       While( not DMSQL.SQLQParts.eof ) do begin
  48.          Inc(Registers)    ;
  49.          BufDataset1.Append;
  50.          BufDataset1.FieldByName('cateid').AsInteger := DMSQL.SQLQCate.FieldByName('ID').AsInteger;
  51. //         BufDataset1.FieldByName('itemid').AsInteger := DMSQL.SQLQParts.FieldByName('itemid').AsInteger;
  52.          BufDataset1.FieldByName('itemid').AsInteger := Registers;
  53.          BufDataset1.FieldByName('category').AsString := DMSQL.SQLQParts.FieldByName('category').AsString;
  54.          BufDataset1.FieldByName('masterpno').AsString := DMSQL.SQLQParts.FieldByName('masterpno').AsString;
  55.          BufDataset1.FieldByName('partnumber').AsString := DMSQL.SQLQParts.FieldByName('partnumber').AsString;
  56.          BufDataset1.FieldByName('itemname').AsString := Copy(DMSQL.SQLQParts.FieldByName('itemname').AsString,0,150);
  57.          BufDataset1.FieldByName('itemdescription').AsString := Copy(DMSQL.SQLQParts.FieldByName('itemdescription').AsString,0,150);
  58.          BufDataset1.FieldByName('type').AsString := DMSQL.SQLQParts.FieldByName('Type').AsString;
  59.          BufDataset1.FieldByName('Rev').AsString := DMSQL.SQLQParts.FieldByName('Rev').AsString;
  60.          BufDataset1.Post;
  61.          DMSQL.SQLQParts.next;
  62. //        if( registers > 100 ) then break;
  63.       end;
  64.       DMSQL.SQLQParts.close;
  65.       found:= BufDataset1.Locate( 'cateid' ,DMSQL.SQLQCate.FieldByName('id').AsInteger , [loCaseInsensitive, loPartialKey]);
  66.  
  67.   //    BufDataset1RecNo:=RegAnt;
  68.       if( found) then begin
  69.          BufDataset1.edit;
  70.          BufDataset1.FieldByName('MasterPno').AsString:= 'Regsitros '+ Inttostr(registers);
  71.          BufDataset1.post;
  72.        end;
  73.       DMSQL.SQLQCate.Next;
  74.    end;
  75.    BufDataset1.Active:=true;
  76.    DataSource1.DataSet.First;
  77.  
  78. // En transfer data
  79.  
  80.    VirtualDBTreeEx1.Header.AutoSizeIndex := 0;      // adjust width of the 1st column when tree width changes.
  81.    VirtualDBTreeEx1.Header.Options := VirtualDBTreeEx1.Header.Options + [hoVisible];  // Show the column headers of the tree
  82.    VirtualDBTreeEx1.TreeOptions.PaintOptions := VirtualDBTreeEx1.TreeOptions.PaintOptions - [toThemeAware];
  83.  
  84.    VirtualDBTreeEx1.ParentFieldName  := 'Cateid';  // field used to group the records by their key field
  85.    VirtualDBTreeEx1.KeyFieldName     := 'itemid';           // unique identifier of each record
  86.    VirtualDBTreeEx1.ViewFieldName    := 'Category';       // Field to be displayed in the 1st column
  87.    VirtualDBTreeEx1.DBDataFieldNames := 'MasterPno;PartNumber;itemname;itemdescription;type;Rev'; // other fields to be displayed in additional columns
  88.  
  89.    VirtualDBTreeEx1.Header.Columns.Clear;
  90.    with VirtualDBTreeEx1.Header.Columns.Add do   // The 1st column is field "Text1"
  91.     begin
  92.       Text := 'Category';
  93.       Width := 60;
  94.     end;
  95.  
  96.    with VirtualDBTreeEx1.Header.Columns.Add do   // The 1st column is field "Text1"
  97.     begin
  98.       Text := 'MasterPno';
  99.       Width := 120;
  100.     end;
  101.  
  102.     with VirtualDBTreeEx1.Header.Columns.Add do   // The 1st column is field "Text1"
  103.     begin
  104.       Text := 'PartNumber';
  105.       Width := 120;
  106.     end;
  107.  
  108.     with VirtualDBTreeEx1.Header.Columns.Add do   // The 1st column is field "Text1"
  109.        begin
  110.          Text := 'ItemName';
  111.          Width := 200;
  112.        end;
  113.  
  114.     with VirtualDBTreeEx1.Header.Columns.Add do   // The 1st column is field "Text1"
  115.     begin
  116.       Text := 'ItemDescription';
  117.       Width := 200;
  118.     end;
  119.  
  120.  
  121.     with VirtualDBTreeEx1.Header.Columns.Add do   // The 1st column is field "Text1"
  122.     begin
  123.       Text := 'Type';
  124.       Width := 60;
  125.     end;
  126.  
  127.     with VirtualDBTreeEx1.Header.Columns.Add do   // The 1st column is field "Text1"
  128.     begin
  129.       Text := 'Revision';
  130.       Width := 80;
  131.     end;
  132.  
  133. //    with VirtualDBTreeEx1.Header.Columns.Add do   // The 1st column is field "Text1"
  134. //    begin
  135. //       Text := 'Category';
  136. //       Width := 200;
  137. //    end;
  138.  
  139.     FormPartsTree.Top:= (FormMain.ToolBar1.Height *2) + FormMain.JvOutlookBar1.top;
  140.     FormPartsTree.Left:= FormMain.JvOutlookBar1.Width+20;
  141.  
  142.  
  143. //    VirtualDbTreeEx1.Nodes();
  144.  
  145. //    ShowMessage( inttostr( BufDataset1RecordCount));
  146.  
  147. end;
  148.  
  149.  

 

TinyPortal © 2005-2018