Is there any easy way of making able to select from DBGrid just like selecting range in excell file?
http://docwiki.embarcadero.com/Libraries/XE5/en/Vcl.DBGrids.TDBGridOption
http://docwiki.embarcadero.com/Libraries/XE5/en/Vcl.DBGrids.TDBGrid.SelectedRows
http://docwiki.embarcadero.com/Libraries/XE5/en/Vcl.DBGrids.TCustomDBGrid.SelectedField
http://docwiki.embarcadero.com/Libraries/XE5/en/Vcl.DBGrids.TCustomDBGrid.SelectedIndex
It seems you can have any number of ROWS selected using dgMultiSelect option.
However for the columns your choice is between select nothing, select single, or select the whole row (using dgRowSelect) and there is no option to select few of those.
I think you'd try your chances using VirtualTreeView in Report (ListView) mode, though it would need wrting some code
Related
I have a budget spreadsheet for simple money transactions. One of the columns is the transaction category (e.g. Grocery, Auto Supplies, Insurance, Entertainment, etc.)
Rather than spell out, let's say, Insurance, in a given cell, I would like a list of possible values to appear, so that I can select one of the values (e.g., Insurance) and have Excel put that value in the cell for me. That way I make sure that Insurance is spelled the same each time I use it.
Is there an easy way to set this up in my workbook, preferably without getting into VBA coding?
You can create a dropdown lists in Excel. What I found from this video:
"
Select the cells that you want to contain the lists. On the ribbon, click the DATA tab, and click Data Validation. In the dialog, set Allow to List. Click in Source. In this example, we are using a comma-delimited list. The text or numbers we type in the Source field are separated by commas. And click OK. The cells now have a drop-down list.
"
In Vaadin 13, I have enabled "multiselect" for my grids, which works great. However, often, even after filtering, I have hundreds of items (so selecting each of them would be tedious). In an old old gwt "grid" tool I used years ago, they had a checkbox that would appear on the top row/header level that, if selected, would do a select all/unselect all for all the rows in the table (after filtering). Does such a solution exist in Vaadin 13? If not, any (easy and safe) workaround to achieve something similar? (Note: It may be a little trickier to do than it first seems, since the select all/unselect all checkbox should select all items even if they're not being displayed or even in the back-endcache....it should select all records based on the filter condition....)
Grid does by default not show a "Select all" checkbox when you're using a data provider that doesn't have all items in memory. The reason for this is that it has the potential of causing lots of trouble with a big database. You can still explicitly enable it by doing something like this:
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.Grid.SelectionMode;
import com.vaadin.flow.component.grid.GridMultiSelectionModel;
import com.vaadin.flow.component.grid.GridMultiSelectionModel.SelectAllCheckboxVisibility;
((GridMultiSelectionModel<?>) grid.getSelectionModel())
.setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility.VISIBLE);
See https://github.com/vaadin/vaadin-grid-flow/issues/549 for more details.
I created a simple DB with Database desktop (Name, Age, Mail, Place etc.).
One name can include more Places (for example Steve: London, Bukarest, Ukraine).
I want to choose from these places in a new checklistbox or similar component. Is there any way to add these items from the DBGRID into the checklistbox to choose from?
I could not find any tool in the Data controls palette where i can select more items.
dgMultiSelect in dbgrid-->Options allows users to select more than one row.
IIRC it returns bookmarks which are not the easiest thing to work with :(
So I'm messing around with a new project in Delphi 2009 and the default components that can be dropped onto a form for accessing data consist of a SQLConnection, DataSource and SQLQuery. If I add a simple select to the query component, say:
select name from customers
and then drop a DBComboBox on the form and link it up with the DataSource I get a single record in the combo box. After using Google for half and hour to figure out what I was doing wrong it looks like you have to manually add some code to your project which loops through the dataset and adds all the records to the drop down box. Something like:
while not SQLQuery.eof do
begin
DBComboBox.items.add(SQLQuery.fieldbyname('name').asstring);
SQLQuery.next;
end;
And that actually sort of works, but then you get a list in the drop down which you can't actually select anything from. Regardless of the result though I'm wondering why would you even use a DBComboBox if you have to manually add the result of your query to it? Seems to me that if it doesn't automatically populate the db combo box with the result of the query then we might as well be using a non-data-aware component like tcombobox.
I guess what I'm asking is why does it work this way? Isn't the purpose of data aware drag-and-drop controls to minimize the amount of actual written code and speed development? Is there a method that I'm missing that is supposed to make this easier?
A TDBComboBox doesn't get its list of values from the database; it gets its current value from the database. Link it to a field in your dataset, and when you change the active record, the combo box's current value will change. Change the combo box's current value, and the corresponding field's value will change.
If you want to get the list of values from the database as well, then use a TDBLookupComboBox.
This is all covered in the help:
Using TDBListBox and TDBComboBox
Displaying and Editing Data in Lookup List and Combo Boxes
Defining a Lookup List Column
I think you want the TDBLookupComboBox because that allows you to lookup from a list of items where the list comes from a dataset.
In the TDBComboBox, the list is just a TStrings manually filled with data.
--jeroen
DbCombox is a dbaware version of the standard combobox component.
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.