I have searched a database using a query.
The results of the search are displayed in a DBGrid component for the user to select the row s/he wishes to proceed with.
DBGrid always sets the record pointer to the first record in the results set, so a row is always "selected" by default. I need to change this behaviour to no row being selected when the data is first presented so that I can determine if the user has actually made a selection.
Is it possible to tell if no selection has been made, i.e. no row has been selected by the user?
Any help very much welcomed!
You can include dgMultiSelect into DBGrid.Options, then DBGrid.SelectedRows will contain list of explicitly selected record bookmarks. Without dgMultiSelect the DBGrid always track the current dataset record.
Related
First of all, I'm pretty new to Delphi.
I have a DBGrid connected to a DataSource and filled up with data from an SQL server. What I want to achieve is that when I press a button, it brings up a new window with comboboxes/editboxes, all filled up with the previously selected (in DBGrid) row's data and modify them and execute an UPDATE query.
In order to do that, I need the primary key value of the selected record, so my little program would know which row should it display and update.
My question is, how can I get a specific cell value (in this case, an id) of a selected record from a DBGrid?
If you know the column for the ID field you can inspect its Field property. The Fields Value will contain the current ID.
In my app, when I select items from a list using check boxes, their IDs are passed to the controller in ascending numerical order, regardless of the original sequence of selection. I've noticed that the params organize the IDs this way automatically. This results in the selected items being stored and shown without respecting the order they were originally selected. How can I keep the original order of selection? Thank you.
I'm using the latest version of Angular UI Grid and am struggling with how to determine if the focus is currently on the last displayed row of the grid.
The data array is not sorted the way it is on-screen, so I cannot use that info. I read that the visible row cache should be sorted as it is on-screen, but I think that might be related to the old ng-grid. At any rate, if I look at gridApi.core.getVisibleRows(myGrid) it still has the sorting as per the raw data.
I am currently handling the event gridApi.cellNav.on.navigate(newRowCol, oldRowCol). I can see the column and row that the user has the focus on, but I cannot see any values in this event (or elsewhere) that I can use to determine if the row is the last-displayed on-screen. I'd appreciate any tips!!
You should use gridApi.grid.renderContainers.body.visibleRowCache which is an array sorted the way the rows are visible on the screen. You can then check if the row is the last row with something like:
oldRowCol.row.uid == $scope.gridApi.grid.renderContainers.body.visibleRowCache[$scope.gridApi.grid.renderContainers.body.visibleRowCache.length-1].uid
I've noticed that when you have multi-select on in a TDBGrid, have a number of rows selected and delete a record, the record is deleted just fine, but your selection changes below the deleted record. All the rows move up one, but the selection stays in the same location - thus the selection effectively moves down by one record.
Is there an easy way of preserving the selection in a grid when a deletion occurs (or somehow fixing the behavior of the grid)?
I have a dropdown list in which I select how many people are going to a party. When the user changes the value of the dropdown list, I want as many fields as the number selected to appear and hide the rest.
But I don't know how can I hide or delete fields because I don't know their index.
Yes you will need to have the fields you want to hide as a global variables.
You will also need to get the value the user has selected and use that to work out what fields should be removed or added.
One way would be to add all the fields in order to a vector or an array when the screen is initialised. Once the user has selected a value you could iterate through the fields and use the current index of the list and the user selected value to work out if the field should be removed or added.
If you have the field objects, then use Field.getIndex() to find the index of each field within its manager.