Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using DB grids
#1
Never tried any data with IW before, so if there are any secrets, please share.

Tried the demo with TIWjQDBGrid and it worked. But it's using a ClientDataset. Once I replaced that with a real DB connection, the grid just displays "Loading..." and nothing happens. Is it supposed to work?

So, how would you publish any data from the server to a grid?

Can it be editable in the grid, in place, as a VCL grid would do?

Or is this a totally different world and nothing is what it seems?
Reply
#2
Ok, I figured that the magic happens when a dataset is assigned at runtime, as opposed to design time, so it now displays the data.

What's the easiest way to select the columns it displays and hide the others?

Can this grid allow editing the data in some way? And POST edited data back to the dataset?
Reply
#3
Hi
I "fight"  Big Grin   against grid since I started working with IntraWeb. I guess the vcl-grids and the IW-grids are 2 different things.

In the meantime I use iwdbgrids only in readonly mode ; alway with TIWDBGridColumns for each column I want to show.
Without these , you don't habe a current record, the Grid don't synchronized with the Dataset.

One way to posit sync the grid and the dataset , I found here , was an on click event in grid Columns. Here you can lookup the value in your underlaying dataset.

iE.
void __fastcall TIWFrame2::IWDBGrid1Columns0Click(TObject *ASender, const UnicodeString AValue)
      
{
  dstKnd->Lookup(AValue);

   
}
//---------------------------------------------------------------------------



Hope that helps...
Reply
#4
Yes, thanks for reply, it's certainly a very different beast.

However, I do believe it can be useful and this is probably the best forum to share any tips & tricks on the subject, unless Alexandre can write an article.

What I have found so far:

1) Linking the grid to data at design time is pointless: it displays nothing, sets no useful properties and does not allow adding / removing columns from the list. It must be set at runtime, at which point it actually reads what it needs and retrieves / displays data.
2) Columns have to be pre-created manually.
3) Styles can be set using the names from here: https://jqueryui.com/themeroller/
4) For editing to work, you have to tell it what the keys are, it would not read it from the dataset, you have to check RowId boxes in all key columns.

Annoyingly, it's not sizing itself right at the start. But will resize itself ni8cely when the browser is resized. Need to figure that out next.

And I've just made my first edit ;-) And it did actually POST it back to the dataset ;-) Couldn't be happier for the moment, but I'm sure there would be a fight at every turn going forward...
Reply
#5
Sounds like your SQL statement is not static so defining columns at design are a not going to work.

Working with IWDBGrids is not as simple as VCL A while back I used String grid to provide user an editable form, but ti was a very simple table where they only updated a few columns. I would resolve the changes back to the table etc... I will look for the code and try to share some details here as I did that about 10yrs ago... LOL
Reply
#6
(02-11-2024, 04:56 PM)lfeliz Wrote: Sounds like your SQL statement is not static so defining columns at design are a not going to work.

Working with IWDBGrids is not as simple as VCL    A while back I used String grid to provide user an editable form, but ti was a very simple table where they only updated a few columns. I would  resolve the changes back to the table etc...  I will look for the code and try to share some details here as I did that about 10yrs ago... LOL

No, it's static alright: a TFDTable. And I did define columns manually at design time. The "problem" is that it does not read dataset at design time and so does not offer adding columns automatically and sets no column properties (like RowID), which is all available in the dataset and VCL grid would do all that seamlessly. It's just more manual than I would like it to be.

There's also TIWDBGrid. And it's also lacking any doco. Can that be made editable? Can it be styled? Is anyone using it? - and if yes, what for?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)