Grid

Q:
I have a varchar field coming from SQL Server that once it is clicked on in the grid, the data is replaced with the word memo.
This field is defined as nvarchar(2000)
From a data modeling perspective, what legnth or condition of a field will make it appear as “memo” in a grid?
I am not sure if this was already discussed.
It seems that any hex value in my grid is coming up as the word object.
Is there a way I see the actual values in the grid?
I also need to see the values that are showing up as Memo, since I am not using a memo field
A:
Anything above 255 I believe.
Any varbinary column with be “object” as it is unknown what it contains.
Any varchar column will be “memo”. Any character fields above the 255 limit will be treated as memos.


using the where clause on the grid seems to work very well for me.
This way, it really is irrelevant the size of the table.

Code:
Lianja.get("PageName.sectionName").where = "value = 5";
Lianja.get("PageName.sectionName").refresh();

Q:
how I can get a record object of the current grid active record?
What I need to do is to allow me to programmatically change the field values of the active record using code
A:
You can update the active record and then refresh that specific record in the grid using oGrid.refreshRecord( recno() )
If the underlying cursor has been dynamically created from a virtual table query you need to specify a primary key and issue the replace statement which will generate the SQL dynamically and execute it.


You can add whatever control you want in the grid.
In this example I create a container with a textbox and a button.

First, create the procedure to create the container and the objects you want.
I did this in the custom library of the page.

Code:
proc mycontainer
mycontainer = createobject("container")
mycontainer.layout = "horizontal"
mycontainer.height = 50
mycontainer.addobject("text1","textbox")
mycontainer.addobject("btn1","commandbutton")
btn1.caption ="Custom Button"

return mycontainer

Then I added a new column in the grid by right clicking the header of an existing column and selecting “Insert Column After”
The in the attributes of the new column, I entered mycontainer in the custom control option.
Then you can see the custom container in my grid.

So – if you need to have a tooltip, You just add it.

Code:
proc mycontainer
mycontainer = createobject("container")
mycontainer.layout = "horizontal"
mycontainer.height = 50
mycontainer.addobject("text1","textbox")
mycontainer.addobject("btn1","commandbutton")
btn1.caption ="Custom Button"
text1.tooltip ="this is tooltip"

return mycontainer


you have some larger field that you want to edit. For those field, use the hyperlink to bring up a dialog box for the edit. This way you have a clean edit, not in a small field, you are using a best practice and properly creating a modern application and you do not lose any functionality.

Have a look at this example.
I concatenated firstname, lastname and address into one field.
If I want to edit that field, I just click on the link and bring up a dialog window.

I accomplish everything I a looking to do in a very intuitive way without trying to re-invent the wheel.

In the linkclick section of my page, I call the dialog window.

Code:
////////////////////////////////////////////////////////////////
// Event delegate for 'linkclick' event
proc page1_section1_linkclick()

Lianja.showdialog("Employee Edit","pgEmployeeEdit",500,500)
// This refreshes the grid to show the new values
Lianja.get("section1").refresh
endproc

The result.

If I was building this for web, I would call the showdialog with a parameter and an action.
In the desktop, it is already on the record pointer.

Try to add some custom delegate to your “text1” (methods like valid() or so…).
That’s easy.

You create your own textbox class with a valid.
Like this.

Code:
define class mytextbox as textbox
proc valid()
wait window "valid"
endproc

enddefine

Then instead of adding textbox, you add mytextbox.


Q:
not found the property that return the number of column..
A:
This should work

Code:
oGrid = Lianja.GetElementByID("page.section").grid
? oGrid.ColumnCount



Q:
If i have filtered grid like this

Code:
Lianja.get("section1").grid.filter = "startsWith(customerid, 'A')"

and I use the code below to move from record to record then it does not work.

Code:
sec = Lianja.get("section1")
        grd = sec.grid
grd.goto(grd.activerow + 1)

It appears that the row is being moved on the filtered gird but I suspect it is moving between rows that are not visible.When the grid is not filtered it works just fine:

Code:
Lianja.get("section1").grid.filter = ""
sec = Lianja.get("section1")
        grd = sec.grid
grd.goto(grd.activerow + 1)



A:
Try doscroll

Code:
Lianja.Get("page1.section1").grid.doscroll(1)

Or

Code:
oGrid = Lianja.get("page1.section1").grid 
lnActiveRow = oGrid.activerow + 1
oGrid.activatecell(lnActiveRow, 1)

In the second example you can specify the column.
In the first one the first column is activated.



 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s