Stemon63 Posted September 30, 2024 Posted September 30, 2024 Hi, a little demo video on a Lookup that perform lookup on a local store (client side). Very fast. In local store there are data that are used very frequently, so they are downloaded one time into client. Is wonderful if Farshad make a local dataset. Non only for lookups, but also for use with grids and forms! (dbedits, combos, Dbtext, etc..) So we could have a complete Crud (complete forms, not just grids) all on the client, with cached updates to the server. Clearly optional. 🙂 DemoLocalLookup.mp4 1
Fred Montier Posted December 31, 2024 Posted December 31, 2024 Yeah... but if only for the fact that uniGUI is stateful, sky would be the limit. But, no ! Once no internet, no unigui server, no connection, no sesssion, hence, you cant use it to save locally (client-side) using regular DB components (and no CRUD for good !). No use for only locally table. There is JSon Dataset Serialize component from a brazilian guy that integrates JSon as ClientDataSet and you can save and update browser localstorage. But, no functioning using regular DB and uniGUI components since you lost stateful sync with the server. Many SPAs (some and some PWAs) do exactly that. Once connection recovered, updates to server. And you can do that with some JS libs and circumvent limitations of stateful format application as uniGUI/Intraweb. An example: see the same feature in Youtube Mobile. Some operations are saved in local storage first (like add to list, watch later, likes etc). Then you phone recovers connection, it will update you profile at server-side in background. Same problem I solved using just JS to the Todo List App published here. uniGUI is used only in active connections so it works in mobile with unstable connections (no FMX slide of hand or browser embedded). Another scenario, "on the field" data collection, outdoor sales, audits, often we got the same problem. So, uniGUI can not work in this problem if the internet connection is unstable. Hence, people go to FMX to keep local tables. I'm planing an update to Code Injector where we'll have Json ClientTable (based in Dataset serialiize Json Client component) to work directly with local storage, among others new stuff. By the way, TMS Webcore, advertised as a TRUE PWA/SPA creator, got some problems here too. Don't know if they got it fixed. 2
Stemon63 Posted January 8, 2025 Author Posted January 8, 2025 Hi Fred, please update me on Json ClientTable. But an "adapter" with client components (better if DB Components) is very useful.
Fred Montier Posted February 23, 2025 Posted February 23, 2025 Hi folks... Does not work like that. You must have a real PWA to make LocalStorage works as a temp db off line (Json/CSV adapter). And this level wont interact with uniGUI DB components, and this is the point here. The best you can do is check when on-line again and update your data in the server. But i'm trying to do all JS. No Ext.JS or uniGUI Ajax back and forth. A good start point is to learn how Hypergrid will in fact work with data store. If it only works while session is alive, cant see the point here, only some lower data traffic. But again, I cannot see the benefit. So, go FULL PWA and merger with a uniGUI when on-line again. I'm experimenting with: https://github.com/localForage/localForage?tab=readme-ov-file https://github.com/agarwalnitesh42/tiny-localstorage-db I was adapting the TODO (tasks) simple APP. It is in uniHTMLFrame and at the end, made no sense using uniGUI just to fire some ajax and sync with your db. Could also be done with json and using localstorage. Worked nice this way. And recently I dropped the update as "Table" (adapter) and got into a dead end sine there was no need for using in uniGUI. Hypergrid should work with something similar since it supports data adapter to ext.js data store, as far as I read. BUt i'm not very aware of this format since I only leran about in WhatsApp Web (hacking with Tinject). So for now... not working properly, no need with need or useful with uniGUI. Remember that uniGUI is a stateful and SPA app format... In fact, this only would make sense like 15-20 years ago when Internet connection was not so reliable and not available everywhere.
Fred Montier Posted February 23, 2025 Posted February 23, 2025 FYI, I'm using for dataset, this resource code below. Made to Delphi and very easy to use. But, is for Delphi "Dataset scheme" , hence stateful and works perfectly with uniGUI. If you intention is to add Json support as a table dataset without JS code, this is the way to go. I made this a whole component that will be available in the next CodeInjector package. This will integrate a lot of JS libs using Json as DB in browser localstorage. But this only works in session to support uniGUI Db component, hence, not good to work off-line. The point here is to make more practical/easy to import already done JS projects using JSon. Code and examples at link below: https://github.com/viniciussanchez/dataset-serialize Also check out https://jsontodelphi.com/ From Marlon, same author of Falcon Package for uniGUI. Easy to convert json to a class, and make a structure to merge with Dataset serialize. In 2 minutes you can make any API working in Delphi as a native dataset without Firedac. Keep in mind that JS is a very messy language/solution* and is no even close to the power of pascal/Delphi/VCL/FMX flexibility. I do avoid it where ever possible. But invested the last two years learning JS and Ext.JS to improve uniGUI apps. *Hence so many frameworks, so many half solutions, so many workarounds...etc. 1
Stemon63 Posted February 24, 2025 Author Posted February 24, 2025 Hi Fred, we are on the same wavelength. I'm not looking for a "persistent" dataset offline, which would still be very convenient using solutions like IndexedDB or Localstorage. Instead, I'm looking for the "cached updates" solution totally on the client. This allows you to carry out all CRUD operations on the client side (Insert, update, delete) and then transport them to the server when the job is finished. All with the aim of avoiding continuous chatting between client and server. Imagine 1000 users inserting continuously invoices with many rows. This is already ALMOST ready to work with HyperGrid, but there are some things wrong. It would take some javascript code to do checks and calculations in javascript directly on the client (there are no examples on this), and Hypergrid would not have to call the server on insert or delete records. But this only affects Hypergrid. Instead, what is missing is a totally client dataset to which to hook not only Hypergrid, but also all the other DB controls. Only in this way can I scroll the grid and manage the individual fields in DBedits, without loading them every time from the server. I hope I was clear, sorry for my english. In this way I would be able to manage thousands of users, as the interaction between client and server is very small. Ideally the clientdataset should load from a json (or from a dataset on the server, but directly json would be much more performant if the json comes from another source, such as a remote service DB) and return the json updates via a ServerApplyUpdates. In a distributed application, in this way, one would even avoid using the datasets in the Unigui server, which take up a lot of resources and remain open as long as necessary.
Fred Montier Posted May 29, 2025 Posted May 29, 2025 I have done some research on this topic and there is some JS libs to do that. Small footprint. But no time to implement. Github has some things to start, if you "abla" JS: https://www.sitepoint.com/9-javascript-libraries-working-with-local-storage/
Recommended Posts