How can we maintain the insertion order in SmartGwt ListGrid - smartgwt

There are some elements in my ListGrid which are coming from the DataSource.At client side I am adding some elements in it from multiple drop downs.I was able to save it Also.
In that Listgrid after adding some elements i am rearranging the elements by setting the ListGrid Property setCanReorderRecords(true).
In this change Order i have to save and fetch the Listgrid Record.
Example-
Combobox1 Combox2 ADD_button
id name value
1 aa 22
2 bb 33
On add button click I have added Selected elements from Combobox in the Listgrid.and change the sequence like....
id name value
5 DK 99
2 bb 33
1 aa 22
In the same order i have to save & fetch the data from the dataSource.

You need to store the sort order in the database. After a fetch you just need to sort the ListGrid by the sort order field.
Now you need to register a drop handler to adjust all the sort order fields of the records involved in the resorting process.
Addditionaly I would recomment to register a sortChangeHandler so, that reordering is only enabled when the ListGrid is sorted by the sort order field.

Related

Auto populate field(s) based on text value Google Sheets

I am trying to auto populate fields E3:E99, F3:F99, and G3:G99 based on the text value of fields B3:B99. So when Sam's is inserted anywhere between B3:B99 fields automagically populate with preassigned data. In my case:
E3:E99 will always be 164
F3:F99 will always be 45
G3:G99 will always be 40
Currently am trying to use the following but to no success:
=$B$3:$B$99="Sam's" =$E$3:$E$99="164.00" =$F$3:$F$99="45.00" =$G$3:$G$99=40
and I have it placed in Q3 away from my table so users cannot see it.
What am I missing or not formatting correctly yo auto populate fields based on B3:B99?
I have tried googling as much as possible and have tried a few different appscript methods that did not work.
So I think you will be able to use a simple IF statement logic check combined with an array formula. This is assuming that the values in column B are entered manually. This is the formula to enter into E3. It will automatically check all values in B and output the 124 value when B=Sam's while leaving the value null if it is not Sam's.
=ArrayFormula(IF($B$3:$B$99="Sam's",124,))
This is the formula for F3:
=ArrayFormula(IF($B$3:$B$99="Sam's",45,))
And the formula for G3:
=ArrayFormula(IF($B$3:$B$99="Sam's",40,))

Automatically fill out textbox doble clicking on an item in a listbox

Another beginners question, but this time about MS Access Controls.
I have a form where I have a list box full with many items.
What I need to do is when I double click on one of this item stored in the list box should all the textbox filled with an item stored on a different field from the same row where from my table.
I checked many tutorials already but didn't found a good solution.
Thanks for any help!
EDIT:
I have a table with several fields. The list box have the items from the first field(ID). The rest of the fields(Tile, Delivery Date, etc...) represented by text boxes in my form.
When I double Click on one item from the list box will populate the text boxes.
If I select the 5th item from my list box which represents the 5th row from my table every text box should have their item from the same row from the fields represented in the table.
I only want to edit the data stored in the table with this form.
Ok I finally get a solution for this one.
I using the DLOOKUP to get the data pulled to my form after the double-click event.
Dim ctrloop
For Each ctrloop In Me.lbReportID.ItemsSelected
strReportID = Me.lbReportID.ItemData(ctrloop)
Next ctrloop
Me.txtTitle = DLookup("[Title]", "tblreports", "[ID No] = '" & strReportID & "'")
The loop stores all report ID I have in my table. The DLOOKUP using this as a filter. It's like the WHERE in SQL.
When the program run will fill out my Title textbox looking through the title field in my tblreports table filtered with the strReportID.
It's working similarly like this SQL query which I using in a different textbox:
SELECT tblReports.[ID No]
FROM tblReports
WHERE (((tblReports.WorkPacage) = 'CDS'))
AND (((tblReports.State) <> 'Complete'));

Reordering ADO Recordset columns

I have a recordset with columns
e.j
ID_PEOPLE
NAME
AGE
And I need to reorder this columns to
ID_PEOPLE
AGE
NAME
This recordset is used to fill an Excel spreadsheet and need to change the recordset column order because reordering in Excel is to slow.
Any idea?
Right click on your Table/Query, select Field Editor.
If there are not fields, press CTRL+F.
Drag by mouse fields changing order as you want.
Or, if you have a Query, you may change select field order: select Field2, Field1 from Table.
Or you may physicaly redesign field order in your table/view/procedure.

do some calculations in a table using dropdowncombo

I have a field in my database called 'Stock'. It displays how many items are there remaining for sale.Now I have a dropdowncombo with values like 1,2,3 etc... So now when I select an item in the grid and click the button SELL I would like the 'Stock' field of the item in question (in the grid) to decrease by the amount that was in the combo. So if the 'stock' was 100 and I sell 5 (dropdowncombo value) I would like the grid value to display now 95. I hope you know what I mean... I could do this with inserting a calculated field but I do not want to. Better an UPDATE ... Any ideas
something like UPDATE MyTable set STOCK = (Mytable.fieldbyname('stock').asInteger - dropdowncombo1.value)
dont have delphi here with me so unsure does this work on selected record in the grid...
abstable1.edit;
abstable.FieldByName('stock').value := abstable.FieldByName('stock').value - strtoint(cxcombobox1.text);
abstable1.Refresh;
This does the job ...

Delphi QuantumGrid GetSelectedRowIndex after sorting

I have D2006 and I am using DevExpress QuantumGrid 6 in a project. I am using it in unbound mode. I have several rows and I need to trigger an action when user select a row and click a button. That works fine when the grid is not sorted by user. I use this code to know the row the user has selected:
index := cxMainTable.DataController.GetSelectedRowIndex(0);
cxMainTable.DataController.Values[index, 0];
But when the user sort the grid by clicking in a column header, the index returned is right for the current order displayed but the values the second line returns is the value that you would expect if the grid was not sorted.
Thanks.
You have to distinguish between records and rows.
Maybe TableView.DataController.FocusedRecordIndex is what you want?

Resources