Correct method of Master / Detail changes - delphi

I have two Tables tblMaster and tblDetail with Linked fields, it all works great. But on some rare occasions I need to see all of the Detail files un-linked.
I have tried...
OnButton1Click(Sender...
begin
try
tblDetail.DisableControls;
if Button1.Down then
tblDetail.MasterSource:=nil else
tblDetail.MasterSource:=srcMaster;
finally
tblDetail.EnableControls;
end;
and that does what I need, but it takes a long time with a lot of records in the Table.
In place of the MasterSource, I also tried
tblDetail.LinkedFields:='' else
tblDetail.LinkedFields:='LinkID';
with about the same reuslts.
Is there some faster way to Link / un-link the file displays?
Using D5, Zeos 6 and SQLite3.

You are switching the detail table in and out of filtered mode.
This switching is what's taking up the time.
Because the switch causes a refresh from the database.
As per greymatter's suggestion you'd be better of with to TTable's one permanently linked to the master table and one free.
Another way to speed things up more is to have 2 TDbGrids.
One visible the other one hidden.
If you want to show all records hide the grid linked to the detail table and show the one linked to the free table and visa versa.
That way you'll not incurr the cost of the switch.
You may want to remember syncing the active row on the displayed and hidden grid (if possible) before the swap. Otherwise it might be jarring for the user to see the rows jump around too much.
Obviously you'd need to disable (grey out) the master table's Grid, so as to let the user know he's now looking at the detail table on its own without filtering.
Finally another option is to dispense with the master-detail and show a joined view of both tables.
This means that rows from the master table would repeat.
Something like.
select d.d1, d.d2, d.id, m.m1 from detail d
left join master m on (m.id = d.masterid)
Whether this makes sense in your application you'll have to decide.

Related

React app design: showing record counts for each page in navigation

Building a react app (non-native, with Rails), where there's a side navigation with links to 6 pages.
Each page displays a set of records.
In the navigation I want to display the number of records (total, and new) for the page that link represents.
Should I try not to store the counts, but to run all the queries initially (pre-load) so I can get the counts?
Would you recommend having a parent component around the navigation and the main page that pre-loads and manages the data for the 6 pages so it can have the counts ready for the navigation to grab?
What about when the user removes an item from the page, would you just update the data in the parent component and skip any further db queries?
Or....?
There are of course a number of ways this can be resolved and the optimal way can be subjective based on your specific needs. One possible way to set this up would be to:
Use counter caches to store the count as suggested by max.
On initial page load, query to find the count for all tabs and keep in state in the navigation bar.
For the data on the individual tabs, when data is created or removed just update the count in navigation bar with a callback function.
This way you won't have to run a query to count the items initially and then no further queries or complicated logic is required to keep the count up to date.

How do I make a sheet filter only show checkmarked rows with multiple variables in G-Sheets

I have a spreadsheet in google sheets that has a lot of checkmarks:
I want to create another checkbox filtering system, either at the top, if possible, or on another tab if not. I've tried putting the filter at the top, but as I'm sure you know, it overwrites the data, so no bueno. I also tried this:
with this code:
=FILTER(Movies!A3:P1000,(IF(F2=0,Movies!F4:F1002=0,Movies!F4:F1002=1)))
Which doesn't seem to be doing what I want either? It's showing a random selection, it seems, rather than only the data with the F column being true.
Ideally, you click the checkmarks of the data you want to see, so, if you click the check under Andrew, Addison and Richie, it would only show the rows that had only Andrew, Richie, and Addison's checkmarks. I am fine with making the checkmarks a 0,1,2 list if needed. (Because checkmarks I think are only binary, unless they have an option somewhere to have a third option that I'm unaware of, and marking some data to not be seen if it doesn't have a checkmark would likely require a third option.)
this is what I've got

iOS and SQL issue

I have an app that uses an SQLite database for user choices of backgrounds, icons, fonts, etc. I didn't create it, so, I have to use what I have, as, I have a rather large installed base, and am not inclined to switch to CoreData at this point. Don't want to piss off the current users. I also am not really up to speed on SQLite or CoreData.
I was using a custom grid view to display the backgrounds and icons. All of that has been changed to UICollectionView with a UICollectionViewCell.
In the SQL file, the base set is one table of 16 items. Really two (one for icons and the other for backgrounds). These are a part of the base app. In-app purchasing unlocks other "sets". These other sets are in a second table. Yes, separate tables for icons and backgrounds.
I have changed the ID numbers in the first table to start at 0. Previously they started at 1. I can now select and change both icons and backgrounds at will without issue and get the correctly selected item.
Except... when I select an item that is in the secondary icon or background table.
I have altered the ID numbers in the second table to start at one ID higher than the ending ID in the base set table.
But... the first item in the second table is being skipped. Selection of any item in the second table is showing the icon or background directly prior to the selected item. (ie. I select ID 21, I get ID 20 displayed). The first item in the secondary table is showing the last item in the secondary table.
So, my question... should the IDs in the second table start over at 0? Should they start at 1? Or is there another way to solve the skipping and incorrect selection?
Thanks in advance.

Hiding TcxGridLevel in TCXGrid depending on master record values

I have a TcxGrid which consists of a master TcxGridLevel and 2 child TcxGridLevels (all of which use a TcxGridDBTableView). I would like to hide one of the child levels depending on the value of the master level record values. How do I go about this?
Here is a link to DevExpress describing what you want:
https://www.devexpress.com/Support/Center/Question/Details/Q96738
But this has some disadvantages in my opinion. First it is quite slow with bigger datasets. Second it comes to "flicker" when your master level changes frequently and the grid has to be redrawn. Maybe it is possible to set a filter to your detail-dataset so the details are "empty" when your nmaster has the correct condition. There is a property in TcxGrid to hide empty detail-tabs automatically.
Somewhat out of context but in case the link goes dead again:
1) How can I trigger Level3 OnGetGridView, because Level3 View was not change as I was expected
The OnGetGridView event is raised only once when the detail is first expanded. After the event handler has been executed, the specified GridView’s clone is created and cached so that the event doesn't fire when expanding the same master record next times. If you need the event to be raised later, you can clear all detail clones by calling the master DataController’s ClearDetails method or ClearDetailLinkObject methods.
You can find this information in the "TcxGridLevel.OnGetGridView" topic of the ExpressQuantumGrid's documentation.
2) I am also changing Level2 and Level3 Caption for every Gridview that it showing, but the changing is not automatically, sometime the Detail View need to be close and open again to make the Caption change.
If we're not mistaken, you change the Level's Caption in its OnGetGridView event handler. If so, the new caption isn't applied immediately because painting of the corresponding element isn't completed. As a workaround, you can perform a "delayed" operation by posting a custom message. I've attached a sample project to illustrate this approach in action. Hopefully, it will serve your needs, and adapting it won't be aproblem.

Are jQuery tabs overkill in this case?

I'd like to create a content box with two tabs. Each tab is associated with a table which contain server-side data. My thought right now is just to load the page with 10 rows worth of data for each table and hide/display each table respectively to begin.
I was then going to toggle display of the tabbed content based on either click events on the tabs OR GET parameters relating to which tabbed content is being acted on (through pagination, for example).
Should I just handle this with UI tabs or is toggling display reasonable in this case? Since the user can update their data, I assume that caching via the tab UI isn't helpful in this case.
Thanks,
Brendan
From what I understood, I don't think its going to be overkill. If you are worried about performance, ten rows for 2 tables is just 20, which is not much. Paginating will also get 10 more rows for each 'click' so it's still good there.
Do use tab activation through click events, but also use GET parameters to know in which page the user currently is, from which tab.
Regarding caching data that you know will change, it might be unnecessary (see my 1st paragraph). Caching can sometimes become unwieldy, so don't add an uneccesary layer of complexity.
As someone who suggests simplicity above all else, I'd discard the whole 'tab loading' thing but leaving the tabs per se (i.e. the interface elements that will be clicked) and when the user clicks each tab, it takes to another page with the tabs too, old-fashioned style.

Resources