Better Way to Deal with Data from Database and Lists - database

I have TextField and onChange function it filters ListView, so is it better get whole item from table and save them in list then when change text filter that list or open stream get data from table every single change in search TextField?
I have lists in my app with elements, is it preferable when I go to another page or when I don't use the items, clear them every time or it is ok, it doesn't affect the app?

Related

Grafana custom editor for every query/series

I was wondering if it is possible to write a custom editor (StandardEditorProps) that displays multiple input fields dynamically for every query (every series in the dataFrame).
I would need the same form (labels, bunch of select and text input fields) repeated for every query (I need to get the field names of the query resultset).
These values will be then used to render the custom panel plugin.
If I return, in StandardEditorProps, the entire form, then onChange every select input field is updated with the same value and I cant get the value of every input field in the custom panel plugin as only one customEditor is added in the module.tsx.
On the other hand, If I define multiple custom (and others non custom) editors in module.tsx I can get the values in the panel plugin but I cant make N such forms dynamically.
Hope that makes sense.
Does anyone have any suggestions or ideas how achieve that?

How can i delete empty row in Ag-grid react

I am using ag-grid enterprise in my project where i am inserting data into the grid. Once the editing of data is completed i am pressing submit button to save the entries in the backend. Before saving there are some validations which i am performing by passing gridApi to the method and there gridApi.foreEachNode i am validating the data. I have a new scenario where if all the cells of the row is empty. The row should be deleted so that user should not have to delete every empty row before submitting. how can i delete the row node inside foreEachNode?
I recommend that build up an array of row ids for the empty rows as you iterate through forEachNode, and then once you are done iterating, use the ids from the array to delete the rows.
However, I'd like to recommend an entirely different approach...
That is, don't treat the grid as the "source of truth" for your data.
Rather, keep a data model in your application, and use the grid just as a visual component (though a complex one), that represents the data in your model.
React is particularly suited for this, as you can use, e.g. Redux to represent your model and provide operations on it.
In this scenario, you would do these operations on your model, and then update the grid with the new value of your model. And your model would then be in a good state to send to your back-end.

What is the best way to handle excluding items from a list via a user search?

Say I have a list of items and a user can search through the list. The list will at most be about 100 items all the data exists at run time so when searching no ajax request need to be made to get new list items, I just have to filter all existing items for the search term.
Is it better for performance if I just add class that hides the list items that don't match the search, or would it be better in the render method to only render the items that match the search. Assuming there is no search initially and all items are rendered on mount, wouldn't removing items because they don't match the users search term after mount be more costly than just adding a class to hide these items?
There are click handlers on the items in case it matters.
As the list will only be at most 100 items I would prefer to just hide them via a class but am not sure if this is really the react way to do it.
I would go with re-rendering the result list to only display the matching items in the list.
Hiding the non matching results has several drawbacks:
a bloated html with up to 100% items in display: none in case the search has no results...
it is probably more costly because you're re-rendering the html in order to apply the css class to hide the items
React is clever when it comes to updating the dom, so it's not really "react way" to tell him which items to hide. Just send the new list of items with the propre keys for each one.

Store jQuery objects in DB

I have a few draggable objects which I would like the user to drag around and then press "save" and return to the page the next day to drag them some more.
The draggable objects include dynamic html with event handlers etc.
I want to store these objects in the DB and then be able to reload them.
What would be a good approach to achieve this?
One possible way I came up with is to store all DOM code within a container div, in the DB as a string, and then insert it into the page and run scripts to add new event handlers for the specific elements...
I guess storing them as a string is the best solution. Just put the column type "Long text" in the database!

Oracle ADF: How to filter out rows in RichTable?

I have following requirement.
Display data in a table
Clicking on checkbox filter out currently displayed rows by some condition
Clicking on checkbox once again return data appearance to it's previous state
To achieve this I've ovverided method rowQualifies in my ViewObject which is simple SQL based view object to apply my custom filter logic.
When user clicks on checkbox I refresh view object data to apply filter
viewObject.setDoFiltering(true);
viewObject.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
viewObject.executeQuery();
It works perfectly, data set updates without interacting with database and my custom filter logic applies as well.
But when I need to cancel filter it wouldn't work because iterator doesn't contain anymore previous rows, and I can only load them from database but it means that I can lose my changes already made to view object rows.
So, when I do
viewObject.setDoFiltering(false);
viewObject.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
viewObject.executeQuery();
It will return me those rows that were displayed previous time.
If I do
viewObject.setDoFiltering(true);
viewObject.setQueryMode(ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES);
viewObject.executeQuery();
It will return me all rows, but I will lost my changes already made to view object rows.
My questions is how to avoid it? Maybe there is another way of doing this? Maybe it is possible to do something with RichTable to tell it how to filter rows in memory.
Any advices are warmly appricated!
I believe this can be done using ViewCriteria, to filter means to apply a ViewCriteria, and then disable it to view all your data

Resources