PDA

View Full Version : Moving records in web



SpringBox
2019-11-26, 13:39
Hi guys

In our web app, we are using a grid to choose an existing customer record - click on the row, return the record number, go to that record number & refresh - easy.

We are using Lianja.getCursor("customer").moveBookmark(lnrecno);

Which seems to work fine

However when we change sections, we cannot get them to mirror the change.

We are calling

Lianja.getElementByID("page1.section1").goto(lnrecno);

for each section in turn

How do we get the record number change to be reflected across the app in web? Obviously it works fine in dev but that is totally different.


Anyone got any ideas?

Thanks in advance

Simon

barrymavin
2019-11-26, 17:20
Using record numbers like that is desktop bound. It is better to search based on a key if you need to manually relate sections like that. Why donít you just relate the sections and let the framework take care of it rather than coding things manually when you donít need to.

SpringBox
2019-11-26, 18:22
Thanks Barry

Ok - search on a key and locate the corrct record but what is the best way (syntax) to then update the record for all the sections on the page so that both the display and the edit all works correctly in synch?

If we are not using record numbers (because, as you say, it is not appropriate in web) to tell the section which record to display, how do we do that?

Would it make more sense to search in js or serverside? We have looked at all the web demo apps but cannot see anything like this.

Cheers

Simon

barrymavin
2019-11-26, 18:41
Can you explain what you mean by all in sync. Are you data binding more than one section to the same data source?

Records in a grid are editable both inline and by a slide in Dialog when you double click.

Show me a screenshot.

SpringBox
2019-11-26, 18:55
We have added an additional readonly grid section to allow the user to quickly find a partaicular record. The grid is the only thing in the section

Once they click on a row, we want to take that selected record and change the record pointer in all the other sections that are bound to the same table. This record changing would be the same effect as clicking on navigation buttons - ie all the other sections match the newly chosen record.

If there s a better way than the the way we are thinking, that is great too.

Sent you a screenshot.

Cheers

Simon

barrymavin
2019-11-26, 19:07
Just set a filter on all of the sections you want updated and then refresh them.

Whats wrong with using "Instant Search".

SpringBox
2019-11-26, 20:20
Instant search works great for a quick search but sometimes you want to see all the "Smiths" so you can pick the right one, based on address, postcode, email or something else. Cycling through them one at a time is too slow when there are many.

We have tried setting a filter and it does work in dev and persists but in web it changes for a second then the record reverts to the previous one when the section is activated.

To set the fileter we are using :

lcustid = guid()


function pcust_sgrid_changed(lcustid)
{

// get selection from the grid and mover record pointer.

var lfilter = "cust_id == " + lcustid;

Lianja.getElementByID("page1.section1").filter = lfilter;
Lianja.getElementByID("page1.section1").refresh();

};


Where would be the best place to remove the filter?

Thanks in advance


Simon

barrymavin
2019-11-27, 02:20
As I stated in my email to you...

Your code is all wrong. You need to construct a string on the right hand side of the ==. see below.

function pcust_sgrid_changed(lcustid)
{
var lfilter = "cust_id == '" + lcustid + "'";

Lianja.getElementByID("pcust.welcome").filter = lfilter;
Lianja.getElementByID("pcust.scust").filter = lfilter;
Lianja.getElementByID("pcust.spx").filter = lfilter;
Lianja.getElementByID("pcust.appraisal").filter = lfilter;
Lianja.getElementByID("pcust.wants").filter = lfilter;
};


And the reason the data you just looked up reverts what you have filtered is that you have the grid on the same page so it is refreshed when you select any of the forms in the accordion stack.


Put the grid in its own page and it will work.

SpringBox
2019-11-27, 06:26
Thanks Barry

That works well.

Given the event firing sequence, where would be the best place to automatically remove the filtercondition - section.Refresh() or somewhere else?

Cheers

Simon

barrymavin
2019-11-27, 07:57
Removing the filter will select all records starting at the first.

If you have designed your UI to select records based on clicking on the grid then how else are you wanting to navigate the data.

You could have a section menu on each of your form sections with a single menu pad ďReset FilterĒ or whatever you want to call it.

barrymavin
2019-11-27, 07:58
Thanks Barry

That works well.

Given the event firing sequence, where would be the best place to automatically remove the filtercondition - section.Refresh() or somewhere else?

Cheers

Simon

BTW It would have worked just fine all in one page if you had used the dblclick delegate rather than the click delegate.

SpringBox
2019-11-28, 11:50
Hi Guys

Having tested properly, this works really well in dev.

However we realise that we cannot return a field vaue from a grid in web and so have been trying to return the row number so that we can then use

Lianja.getElementByID("page1.grid1").item(Row,Col) to read the contents of the relevant grid cell (customer_id).

That value will then be used to build the filter expression to find the record as per Dev mode.

We are struggling with the syntax required here, both to get the activerow and to then do get the item(row,col) values.

When we try Lianja.getElementByID("page1.grid1").item(Row,Col) in the console, it just returns an empty object

.ActiveRow and .ColumnCount etc just produce not found errors but we can reference .table and .database

Maybe there is an easier way to do this. Read everything we can find.

Any thoughts?


Cheers

Simon

P.S the infinite grid scrolling in web is amazing !!

yvonne.milne
2019-11-28, 12:37
Hi Simon,

If 'grid1' is the name of the section, you need to reference 'page1.grid1.grid' to reference the grid object in the section.

Regards,

Yvonne

SpringBox
2019-11-28, 13:08
AHA !!

Thanks Yvonne- thought we were going mad....

Simon

barrymavin
2019-11-28, 19:13
You don’t need to do any of that in desktop or web / mobile.

When you position on a row in a grid, the name of the controlsource e.g custname can be referenced as a JavaScript variable.

you can verify this in the browser JavaScript console. Just click on a row then type the name of the variable you want to inspect in the console.

SpringBox
2019-11-28, 19:21
Hi Barry

This works great in Dev but is not working in web - We can access the correct cell value and we are setting the filter correctly but it is not yielding the correct record.

We have tried to get access to the field value directly but believe that has no meaning in web.

You say "When you position on a row in a grid, the name of the controlsource e.g custname can be referenced as a JavaScript variable."

Can you please explain - we don't understand what this means. How can we referesnce this as a JavaScript variable?

We have tried typing in the name of the field in the browser console but just get a "<fieldname> not defined" error as we would expect.

This is the last link before app release

Thnaks in advance

Simon

barrymavin
2019-11-28, 19:28
In your delegate just reference custname (or other fields that you have bound to the grid) as I explained earlier.

Inspect these variables in the JavaScript console as suggested.

barrymavin
2019-11-28, 19:33
A few days ago I gave you some code which constructed a filter expression in JavaScript. You need to go read that again.

A filter expression is applied on the server so it cannot reference variables on the client. You need to construct literal strings.

var filter = “custname=‘“ + custname + “‘“;

which evaluates as

”custname=‘Smith’”

which is sent to that server to fetch the required record.

HankFay
2019-11-28, 21:30
The way I remember it (whether or not it's technically correct :) ) is, using your naming of page a section, page1.grid1 is a section. Page1.grid1.grid is the grid control.

Hank

SpringBox
2019-11-29, 07:49
Hi Barry

Thanks for the reply. Having now done a lot of testing, think we are talking at cross purposes. The filter construction is fine. This seems to be a web issue.

In web, it seems neither the grid.click() or grid.doubleclick() delegates are firing

We have added a menu item and have a working solution lifting the data from the relevant grid cell using :

ogrid.item(lactiverow,lrequiredcolumn);

Hope that helps

Cheers

Simon

SpringBox
2019-11-29, 07:50
Thanks Hank

Yes - you are correct

Thanks

Simon

barrymavin
2019-11-29, 08:33
Did you read my reply.

The click delegate is being called. Look at your previous code. It worked then,

The data bound columns are available as JavaScript variables. I’ve already explained this.

Why are you still persisting to reference the VFP desktop bound activerow and activecolumn .

Just reference the variables as I’ve already explained in the double click delegate. Not the click delegate.

In that delegate you can switch the form section into view also.

SpringBox
2019-11-29, 12:15
Hi Barry

Yes we have read all your replies carefully. We built it as you suggested and it all worked great in dev but not in web.

Please do not think we are beng obtuse, we really need to get this done now. We just do not understand what you mean when you say "The data bound columns are available as JavaScript variables" - how if the delegates don't fire in web?

In our extensive testing today we could not get the called function to fire from either the click or doubleclick delegates in web. The function works fine from a menu in web.

Both using data [ ie functionname("{cust_id}") in the delegate ] and grabbing the cell contents all works perfectly in dev.

We tried "Just click on a row then type the name of the variable you want to inspect in the console." but only got errors as we don't understand what you mean.

Do you mean Lianja console or browser console? That doesn't work in Lianja console [cannot fnd variable] and in browser Console if we put in field names {name} we get we get Uncaught ReferenceError: {name} is not defined. or LOM text ie Lianja.getElementByID("pagename").name, we get undefined.

Are you sure the click and doubleclick delegates are firing in web? We cannot get them to fire on pc or ipad or android.

We would love to do it the way you suggest but the delegates won't fire. Activerow and activecolumn is the only way we can get this to work but it is certainly not elegant.

Have we missed something fundamental here?

Thanks in advance


Simon

barrymavin
2019-11-29, 18:51
The package you uploaded last week used a click delegate. In web. And it worked. I will reinstall it once again and have a look at it when I have a chance. You must have changed something.

barrymavin
2019-11-29, 21:11
The grid is readonly and dblClick is used to edit a row. This was causing an issue.

I have corrected this in the next build. So use DblClick on a readonly grid as the delegate and just do this. Nothing else. The grid row will be selected, the record re-read and made current and the form section pcust.scust will be made visible displaying the current record values.



////////////////////////////////////////////////////////////////
// Event delegate for 'dblclick' event
function pcust_sgrid_dblclick()
{
Lianja.showDocument("page:pcust.scust?action=select");
};

SpringBox
2019-11-30, 05:14
Thanks Barry

That makes sense - simple and elegant too.

What RC is that likely to be?

Cheers

Simon

barrymavin
2019-11-30, 05:34
Thatís up there already. RC99.