How can I select a specific row and column from a DBGrid lazarus? - pascal

I want to save a specific value that is on a specific row and column. How I can do this? I already search, but I didn't find anything

One doesn't save a value from the grid but rather from the underlying dataset. The following is for Delphi, but I understand that Lazarus is near enough the same. Let's say that the grid is displaying data from a query qTest that has fields id, surname, forename, date of birth (DOB). In Delphi, one can automatically have variables created with names qTestID, qTestSurname, etc. Another way of referring to the variables is by use of the 'fieldbyname' syntax - qTest.fieldbyname ('surname').asstring.
Write a dblClick handler for the grid: when one gets to the row that holds the required data, perform a double click. In the handler, the fields of the row will now be available as qTestID.asinteger, qTestSurname.asstring, etc.

Related

SSRS Static fields in groups

Good afternoon!
I have created a report with the wizard to create a matrix that is grouped and has drill down rows. I have added filters to the rows and columns and it works great! I then copied that matrix and modified the filters, so I had two matrixes.
But what I really wanted was those two rows in the same matrix, just in different row groups. So I added another group, using the adjacent below option, and then added all the child groupings. However, when I run the report it shows the values for the first row of the drill down data.
When I look at the groupings I can see the one I did manually has a 'Static' field in each row grouping but the ones that the wizard did (with the red ?), they don't have that "extra" row:
What do I need to change or how do I need to add my groups so that I don't get that "static" row and not show the data? I have the visibility set to 'Hidden' and the toggle set up for the prior grouping set data.
Assuming a few things....
the data comes from a single dataset
You are differentiating between Property and Violent crimes by filtering on a column, I'll call it IncidentGroup for the sake of illustration..
I've understood your question ! :)
Get to the point where you had just a single tablix filtered to show 'Property crime'.
Now remove or edit that filter so it shows all the data you need in the report.
Finally, right click on your Matrix1_IncidentCategory row and add a parent group, choose IncidentGroup (or whatever the column is actually called) and check the box to add a group header.
That should be it, there is no need for a second tablix.
Without knowing how you are filtering currently it's hard to give a complete answer but this should get you close, if not all the way there.
If this doesn't work for whatever reason, please post sample data from your dataset output and your current filters.

GWT (smartgwt) grid sort selected records top

I have a grid where the user can select records via checkbox in front of every record. Now I have a requirement to sort the records based on their selection, so that all selected records should be placed top, followed by the not selected ones.
Is there any standard function to achieve this? As an alternative I thought of saving the selection state as an attribute on every record and sort based on the attribute.
The code for the column is:
gridRealmDt.setSelectionType(SelectionStyle.SIMPLE);
gridRealmDt.setSelectionAppearance(SelectionAppearance.CHECKBOX);
I try to describe the code I use as the affected code is deeply nested in our own framework classes.
gridRealmDt is a subclass of smartgwt ListGrid. In my Dialog a create an instance of the grid which creates an instance of a database bound datasource. When the dialog is loaded the records are fetched from the database and after that a registered an dataArrivedHandler where I select the records which match records from another table.
I tried to place the selection attribute in an extra field and use that for sortig before my other sort criteria, but this does not work. Here is the code for the field I am using.
ListGridField txtSelected = new ListGridField(SELECTED, "");
txtSelected.setHidden(true);
txtSelected.setSortByDisplayField(true);
txtSelected.setCanSortClientOnly(true);
When I do not set the canSortClientOnly property the order by is sent to my database resulting in an error, as the table does not contain that field, so I set the property. Now I get following error
Removing field from the sort Specifier array because it specifies canSort Client Only: true and all data is not yet client-side.
I also tried to use a sortNormilizer on the Name field which is my main sort criteria, but the normalizer is called before the selection value is set to the record.
record.setAttribute(CARealmDS.SELECTED,selected ? "a" : "b");
I also cannnot find a way to call the normalizer when selection changes.
Currently we are using Smart GWT Version 6.0p.
I don't think there is any standard function. Just use grid store update. Place checked items first.

Sorting on hidden data

Is it possible to have data in a Handsontable sorted by a field which is not displayed? I have a grid of data which I would like to display that contains a column called "sortOrder", but I don't want to display this.
The sorting needs to be done client side because events are coming in over web sockets and need to be reflected in the table.
If you're not showing the column then I assume you're not expecting the user to be able to manually sort by this hidden column. Therefore, why don't you simply sort your data array with native JS? At any point during execution you could have a function which sorts by this hidden column and then just don't render this in your Handson definition.
So yes, the answer is it is possible. The not showing of a column is as simple as defining the columns option and not including a column for this hidden value.

How to allow user to add information for every fields in forms

i have a strange user request: they want to be able to say for every fields in every forms from where they get information used to compile it.
value must be selected from a list
essentially iam looking a way to avoid to double the fields.
one way can be add a M:M table where link field-name and information-source
but using this for retrive from real data table only fields derived from an info-source can be really bad
EDIT
to be more clear the solution i want to avoid is to have a data table like this:
fieldname1
fieldname1Origin
fieldname2
fieldname2Origin
fieldname3
fieldname3Origin
...
but i do the link table in this way:
FieldName
OriginId
i have to map oll field names and to search in it with string name when i need to query data table i have to do something like this
select
case when (exists select 1 from LinkTable where FieldName='fieldname1' AND
OriginId=SelectedID) then fieldname1
else NULL
end
for every fields
What about mixing several controls, such as a combobox with all lines, that would trigger the display of all columns of that line.
Something like that (I am currenlty working on that project):

VB6 and data-bound MSHFlexGrid, moving and populating columns

I'm working on a VB6 program that connects to a SQL Server 2008 R2 database. In the past I have always used the MSFlexGrid control and populated it manually. Now, however, the guy who is paying me for this wants me to use data-bound grids instead, which forces me to use the MSHFlexGrid control because I'm using ADO and not DAO. So, I have two questions...
First, how would I move a column in a MSHFlexGrid? For example, if I wanted the third column to appear as the sixth column in the grid, is there a simple single line of code that would do that?
Second, believe it or not, I've never had to do anything in a grid other than display the data, as is, from a recordset. Now, however, I have a recordset with some fields that contain just ID numbers that refer to records in other files - for example, a field containing an ID number referring to a record in the Customers table, instead of the field containing the customer's name. What is the easiest way to, instead of having a column showing customer ID numbers from the recordset, having that column show customer names? I thought I read somewhere that there's a way to embed a sql command in a MSHFlexGrid column, but if there is I wouldn't know how to do it. Is this possible, or is there a simpler way to do it?
TIA,
Kevin
The column order would typically be handled by your SELECT statement.
Say you have a Pies table that has a FruitID foreign key related to the FruitID in a Fruits table:
SELECT PieID AS ID, Pie, Fruit FROM Pies LEFT OUTER JOIN Fruits
ON Pies.FruitID = Fruits.FruitID
This returns 3 items: ID, Pie, and Fruit in that order.
Moving columns after the query/display operation is rarely used, but yes ColPosition can be used for that.
Wow! VB6.... Back to the future! :-)
You can move Columns using the ColPosition Property.
This article shows how you could setup the grid to display hierarchical data.
If you just want to display the customer name on the same line as the main data then that is doable as well by just creating the proper SQL for your data source. For that matter you can control the column order the same way as well.
Now, how about considering upgrading to .Net? Just kidding..... No, I'm not. OK. I am, maybe. :-)

Resources