webix resets treetable state after adding/deleting nodes - webix

In treetable I have one of the columns - dropdown list. As default its value is "no changes". When I add/remove nodes from tree, for all nodes dropdown list returns to the default value "no changes". How can I prevent it?

If you have a native HTML select rendered as a part of tree item, there is no easy way to preserve its state, as tree can repaint the item at any time.
Check http://webix.com/snippet/147906cc , it shows how you can store state of select item in the data object, so it will be correctly preserved during repainting.

Related

Delphi TQuery result set - how to avoid the caveats of having RequestLive set to true

I use Delphi 10.2 with ComponentAce's Absolute Database framework. So my question here can pertain to TAbsQuery or, I presume, the conventional Delphi TQuery class.
My database has a date field named lastViewed. I have the RequestLive set to true so that any changes made to various fields in the current record are persisted to the table. Additionally, in my BeforeScroll event (i.e., prior to advancing to another record) the lastViewed field is updated to the current date. It works just fine. However, I have a menu option that displays a list of all records sorted by the last viewed date. In other words,
SELECT * FROM myTable ORDER BY lastViewed
It looks just fine when the results are initially shown in the DBGrid (TAbsGrid, in my case). But as I scroll down the list, the lastViewed field is updated and that record is pushed to the bottom of the grid. I would like the original order of the list to be preserved as I scroll up or down the list.
Turning LiveRequest to false will obviously trigger a database error when updating the DB fields in my BeforeScroll event.
The same issue would occur if, say, I want to show results for all records having the myFavoriteColor field with a RED value. Changing the myFavoriteColor value to GREEN, that row would disappear from my query results list.
Is there a way to keep the current query results in tact, while still being able to update the underlying table with new data?
Thank you for reading this.

How to reset/clear the active record after a TDataSet.Locate successfull

I am trying to modify a legacy Delphi 2007 application.
Under certain conditions, I want make sure no record been selected for a table by supply invalid keys before calling the TDataSet.Locate function. The general process is:
User select an item (Key No. 1 for example) in a list from Grid
User do something in other screens (X, Y, Z for example) which all using Key No. 1 to retrieve data in other tables
But on one screen (say it to be screen X), I want the grid forget the
selected item, but should still had the list and data, just nothing been selected again. and all other screen should not load any data unless the user starting from step 1 again to select an item from the list again.
The current application will always have a item selected without user specifically select anything, which will be the first record in the list, and it will almost certainly never be the right one. It can be slightly improved by make sure the most recently change record been selected by default, which will be right sometimes but not most of the times. I think a better approach would be
ask the user always to select an item in the first screen in the list, and again after they finished screen Z.
So the first thing I tried is to do a locate for invalid index. But of course it doesn't working as Locate will not change the last active record if new Locate failed (find no record). Consequently, there will always an activated record.
My question is, is there any way I can reset/clear out the activate record after there been successful Locate?

How can I auto-fill Edit fields by using different options of a drop-down list?

am using a VCL form in Delphi, where I have put about 10 edit boxes.
These Edit boxes contain values that are related to specific models of solar panels.
These values are needed in order to calculate the output power of a solar panel.
So far, I am able to type these values in every run with the command:
c0:= StrToFloat(Edit1.Text);
for c0 to c10. But, instead of asking the user to manually type these 10 values in each run, is there any way to let the user select one option (i.e. a model of a solar panel) of a drop down list and these values being filled automatically for them?
Does the combobox do such a thing and if yes, how exactly? I am sorry, I am a very new Delphi user. Any help much appreciated.
Set the combo box Style to csDropDownList.
Populate the combo box Items with appropriate values for the user to select.
Add an OnSelect event handler. This will fire whenever the user selects a new item in the combo box.
Implement the OnSelect event handler by populating the edit controls with appropriate values, based on the value of ItemIndex.
You will need to think a little about the UI. If the user changes the combo box selection, then the edit control values change. But can the user then modify the edit controls? Now the values in the edit controls no longer match the combo box. Is that what you want? I guess that the UI needs a little more polish.

How to fill a combobox when a row in a dbgrid is selected?

In Delphi 2007 I have a DBGrid. I need to fill a ComboBox when a row in the DBGrid is selected. The data in the the ComboBox depends on the selected row, and can be different for each selected row.
The DBGrid contains products orders. When an order is selected, I need a ComboBox to be filled with batch numbers of the product in the order. This batch number is saved in the order record, when the order is executed.
I could not find a onSelect or onChange event, which I could use to do this.
So how can I do this?
You should use TDataSet.AfterScroll event
If the data comes from a DataSet in a DataModule, as it looks from comments to #Roman response, you can rely on TDataSource events.
If your datasource is also located in the datamodule, you can place a new DataSource in the form itself (IMO is where it belongs).
Then, use the TDataSource.OnDataChange event, from help:
Write an OnDataChange event handler to take specific actions when a field in the current record has been edited and the application moves to another field, or when the current record in the associated dataset changes. OnDataChange is especially useful in applications that must synchronize data display in controls that are not data-aware. This event is typically used to make sure the control reflects the current field values in the dataset, because it is triggered by all changes.
The Field parameter is nil when the linked dataset is moving to a new record or refreshing a record buffer. The Field is not nil when the changes belong to a particular field (a user or the program itself changing it's value).
I suggest the double click event (OnDblClick) to catch when the user clicks with his mouse and OnKeyPress for the Enter key (Key=#13)

Why would a SharePoint lookup menu require a double-click to select an item?

I have a SharePoint feature which programatically creates 3 lookups in a custom list, one from each of 3 different lists via extremely similar CAML markup.
The only differences in the CAML are the List, ID, Name, DisplayName and StaticName properties yet one of these lookups looks slightly different (has a slightly more "modern" drop-down arrow) than the other two and this same menu requires I double-click in order to select an item instead of single-clicking as I do with the other lookups.
Might anyone have seen this before and have an idea of what I might look into to make this lookup operate as a single-click menu?
The style of dropdown displayed is usually related to the number of items, although it also renders as a standard select element when viewed in firefox.
For any other field type it would make sense to create a custom field control, but due to code that expects things to be named "Lookup", lookup fields are next to impossible to extend.
The best way to customize a specific field is probably with javascript/jquery. When you click on the dropdown arrow, ShowDropdown (in core.js) is called. This creates a select element with options set from the pipe delimited list in the choices attribute of the textbox.
Add some code to the page so that on load EnsureSelect and FilterChoice or similar are called to create the select element. Set properties on the textbox and select elements so that the textbox as hidden and the select element is a visible dropdown. Have SetCtrlFromOpt called on change rather than on blur/double click so that the control that the server will read and save is properly updated.
The same approach could be used to keep the combo box but add a click event to set the value rather than requiring a double click.
How many items has the source list of every lookup field?
Lookup fields shows a "Combo" when the source list has 10 items (I'm not sure if 10 item is the exact limit). When the source list has more than 10 items the lookup field shows a "ListArea" control that works as you said.
I have exactly the same problem. One difference I have noticed is that the one listbox that requires a double-click is a lookup field, whereas the one that doesn't is a choice field with pre-populated choices. Don't know if that helps.

Resources