I have a cls file which contains an ultragrid, a ProBindingSource which contains the temporary table & 2 buttons.
On click of one of the buttons in my cls form I want to fill my ultragrid based on what is entered in the ultraTextEditor; if nothing is entered then I want to display all records otherwise just display the one customer record. I use the following code...
if ultraTextEditor1:Text = "" then
createAll().
else
createOneRecord().
bindingSource1:Handle = dataset dsCustomer:handle.
Methods createAll and createOneRecord go away and create my temporary table records.
This code works first time but if the button is pressed again it falls over with a not available record message. Why is this?
On press of the other button on the cls form I'd like to clear all the records from the ultragrid? It seems whatever I try I get a not available record message. I get a little lost here because should I be referencing the dataset or temp-table?
Thanks, Dez
You need to tell the binding source that there's new data: either reopen the query (and reposition to the previously-active row), or 'disconnect' the dataset from the binding source and reconnect it (pbs:handle =?. Pbs_handle = dataset:handle.).
-- peter
Hi Peter.
I've added
bindingSource1:Handle = ?.
bindingSource1:Handle = dataset dsCustomer:handle.
to click of my clear data button but nothing happens. I've tried refreshing the ultragrid but that hasn't helped.
Dez
I've attached my source. I'm not getting the record not available error anymore, but on click of finding my customer it is not refreshing the browse.
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/source.txt.zip:550:0]
Thanks, Dez
How do I reposition to the previously active row?
Thanks, Dez
Hi, I'm out of the office on vacation. During my absence I will have no or limited access to my e-mail.
For immediate assistance please call our office at +32 (0) 15 30 77 00.
Best regards,
Wouter.
--
Wouter Dupré
Senior Solution Consultant
Progress Software NV
Stocletlaan 202 B| B-2570 Duffel | Belgium Direct Line +32 (0) 15 30 77 00 Fax +32 (0) 15 32 12 60 Mobile +32 (0) 478 50 00 49 wdupre@progress.com
How do I reposition to the previously active row?
You can either do that directly in the UI or in the ABL query (this tells the ProBindingSource to tell the grid).
For the UI, you could store the ActiveRow in a variable and set ultraGrid1:ActiveRow = oMyStoredActiveRow after you've done what you need to do.
Or, do something similar in the query: store the CURRENT-RESULT-ROW and REPOSITION-TO-ROW afterwards; although for more robustness, you should probably store a ROWID or array of them, and use REPOSITION-TO-ROWID. Using the ABL Query approach means you can do this once and reuse it independently of the UI control (so it would also work if you swapped out the UltraGrid for a MS DataGridView).
There are a number of posts on reposition in this and other forums which might be interesting reading.
-- peter
Thanks Peter you've been a big help!
Here is one scenario.
With focus being in searchText (ultraTextEditor), I fetchData based on its text property (press F5 to search).
Focus remains in searchText and the following code snippit allows navigation of the ultraGrid,
which is on another tab (pressing "Enter" sets ultraTabControl:selectedTab:Key).
Using the forms KeyDown event -
WHEN Keys:Down:ToString() THEN
DO:
IF searchText:isInEditMode THEN
DO:
rRow = contactGrid:activeRow.
IF rRow:HasNextSibling() THEN
DO:
rRow = rRow:GetSibling(SiblingRow:Next).
contactGrid:ActiveRow = rRow.
END.
END.
END.
WHEN Keys:Up:ToString() THEN
DO:
IF searchText:isInEditMode THEN
DO:
rRow = contactGrid:activeRow.
IF rRow:HasPrevSibling() THEN
DO:
rRow = rRow:GetSibling(SiblingRow:Previous).
contactGrid:ActiveRow = rRow.
END.
END.
END.