Grid

Q:

I’ve a Form Section, with a Grid Gadget.

If I try to set:

Code:
oGridGadget = lianja.get("mypage.section.gridgadget")
oGridGadget.clear()
oGridGadget.setattr("controlSource", "filterricerca")

I get the error:

gio ott 6 10:10:16 2016
**** Lianja error ****
USE “filterricerca” IN 0
^
File ‘filterricerca.dbf’ does not exist

where filterricerca is a cursor:

Code:
create cursor filterricerca (&cursorField)
select filterricerca
append blank

Is possible to use a cursor as a datasource of a Grid Gadget?

My goal is: create a universal “Search page”.
This must function to look up data on a table or on a query.
Eg:
Item table: search for articles with “screw” in the description, and “12” in size.
Sales Order: search for customer orders of “Bologna”

In the first case is a search on a single table, in the second I have to do a query on Orders and Customers.

In the example I have a table “Articoli” (items) and a VT “VT_Articoli”, accessed via ODBC from a DB FoxPro 2.6 ..

Now..

Name: 2016-10-07 15_16_57-Nuova notifica.jpg Views: 51 Size: 84.6 KB

To do this I set a namespace var:

Code:
namespace MyNameSpace

public m_mainTable
public m_searchtable, m_searchfields, m_searchcaption, m_searchtarget, m_searchcursor, m_searchjoin, m_searchfilename, m_searchorder, p_sRetVal

MyNameSpace.m_searchtable = 'articoli,vt_articoli'
MyNameSpace.m_searchfields = 'articoli.cod_art|;articoli.gruppo|;vt_articoli.ca tmercgam|;articoli.des_web|'
MyNameSpace.m_searchcaption = 'Articolo,Gruppo,Categoria,Descrizione'
MyNameSpace.m_searchtarget = 'cod_art'
MyNameSpace.m_searchcursor = 'cur_articoli'
MyNameSpace.m_searchjoin = 'articoli.cod_art=vt_articoli.cod_art'
MyNameSpace.m_searchfilename = ''
MyNameSpace.m_searchorder = ''

callSupSearch_x(oActivePage.id, oActiveSection.id)


m_searchtable represent the table involved in the query (one or more)
m_searchfields represent the fields displayed by default in the result
m_searchcaption is the relative field caption
m_searchtarget is the returned field
m_searchcursor is the name of the query
m_searchjoin is the relation between the tables

the function callSupSearch_x(oActivePage.id, oActiveSection.id)
call the server page…

Code:
lianja.showDialog("sem_search", "pageSearch", 800)

in the server page I create a cursor, with the “m_searchfields” and the “m_searchcaption”, I create the menu, with the table involved in the query.

Just typing in the Filter cursor, I do a query and refresh the “Results” in the webview.

When the user click on the menu “Articoli”, I update the filtergrid, I create a new cursor with the structure of the table “Articoli” and I display all the columns.. the user can type any search string in any column..
I refresh the query..

For the Filter cursor, I can only use a Custom VFP Section where I change the “Browse or Edit command”…

I can not use the more beautiful “Grid gadget”..

A:

No, it expects a table name.

A2:

I believe you can also use temp tables (at least that how I understand them) instead of a cursor.

If you select into a table that has a name that starts with an underscore, it is not part of the database.
select * from a into _temp1.

You can create a temporary table that is not in the database.

I know of two ways.

1. Create table c:\tempfabio free(Firstname Char(10), Id int)

By using the word free, it keeps it standalone.

2. use a table that starts with an underscore.

Select * from masterfabio into table _tempfabio

 


Q:

On a canvas grid, the selected row has a dotted outline. Is it possible to highlight the selected row with a color?

A:

You can do it through CSS, e.g.

Name: canvasGridCSS.jpg Views: 81 Size: 91.0 KB

Name of control: grdClientList

Attribute
CSS Style: app:/clientlist_section1_grdClientList_cssstyle.css

clientlist_section1_grdClientList_cssstyle.css contents:

Code:
lianja_ui_tree::item:selected {
background:white;
color:black;
border: 3px solid blue;
}

lianja_ui_tree {
font-size: 28px;
}

I changed the setting for “Can select rows” to True and the CSS formatting is working now,

A2:

I was wondering if you were wanting to change the border as you moved the mouse over the rows rather than when you actually selected a row.

If anyone else is interested in this, you can use the ‘hover’ pseudo-state, e.g.

Code:
lianja_ui_tree::item:hover { 
	border: 3px solid blue;
}

Q:

I am trying to sort my grid section in descending order on column 0. below is the code I have tried. It seems like it should work. Does anyone see an obvious problem.

Code:
oGrid = Lianja.get("rfrmain.RFRList").grid
oGrid.sort(0,-1) //sorts grid in decending order by rfr no ---not working
oGrid.refresh()

A:

Make sure the ‘Sortable’ attribute is checked (True) for the Grid Section (in the Details attributes).

You won’t need the refresh().


Q:

How do I specify the background color for a row or cell in custom vfp section grid?

A:

Cell dynamic background/foreground attributes are currently only available on Grid Section Columns.

If you just want to color the selected / hovered over row, this can be done through CSS : http://www.lianja.com/community/show…ighlight-color.


Q:

I have a grid bound to a table in a custom VFP Section.
As users fulfill different actions, I need to be able to change the color of specific cell backgrounds.

I know the cell I want, how do change the backcolor programmaticly ?
I have looked at Dynamic Cell Background, but this is not based on a table value.

would it be something along of the line of

sCell = namespace.grid.item(x,y)
sCell.backcolor=’red’

I am using a custom VFP section and hand creating all of my objects.

Meaning – in my code, I use addobject(), so the attributes need to be exposed on a programmatic level.

A:

As far as I am aware, you can access the backcolor and forecolor of the column, but not an individual cell.

Grid.item(x,y) returns the text from a cell, not an object reference to the cell.

 

 


Q:

I have grid named verGrid in custom VFP section.

How would I reference an individual column to make it read-only or change the header?

A:

vergrid.columns(1).readonly = .t.


Q:

The highlighted row in a grid section seems to always be the first row in the grid when the page is initially displayed.

How can I have the grid highlighted on a row of my choosing when the page is displayed?

I have a page with a grid section on it bound to a table in my database called CLIENT.

In the DblClick delegate for the grid section, I capture the Cid column value from the CLIENT table to a public variable and then ShowDocument() to a different page in my app.

When the other page is closed, I return to the original grid section page and in the Activate delegate, I have the following

Code:
proc clientmaint_section1_activate()     
    Select CLIENT
    Locate for Cid = LastClientID
    Wait Window "Record Number = " + Transform(RECNO("CLIENT")) + "... "+CLIENT.cid Timeout 1.5
    Lianja.GetElementByID("clientmaint.section1").Goto(Recno("CLIENT"))
endproc

The Wait Window command shows the table on the correct record with the correct cid, but when the page appears, the grid’s highlighted row is the top record.

I have also tried to use the following:

Code:
Lianja.GetElementByID("clientmaint.section1").Next()

A:

You are trying to use the Next method on a section rather than on a grid. Try something like…

Lianja.getElementById(“clientmaint.section1.grid1” ).Next

the correct notation is :

Code:
 Lianja.getElementById("clientmaint.section1").grid.Next()

Q:

Add a blank grid section to an application: In a JavaScript application, I am trying to add a blank grid and then populate it later from an array using additems().

A:

Here’s what I did in on app:

1) created a table with the required fields and also had a cSession field of C(26).
2) in the UI, I added a property to a public var oApp of cSessionID
3) this property was, on the INIT of the UI app, set to guid() (this was in VFP, but should work here)
4) I then set a filter on the grid of: cSessionID = oapp.cSessionID — which meant the grid was showing empty
5) Then I could “create” records from anywhere, making certain to use oapp.cSessionID as the cSessionID of the table.

The same could be done with a VT and a parameter for cSessionID of course.

In the close of the database (assuming you don’t close it in the UI), you can delete for cSessionID = oapp.cSessionID.


Q:

grids in a custom VFP section.

using addcolumn, how do I specify the header text and rowsource for the column?

A:

After addcolumn()… you can get objects (column and header)

The Column object (returned from grid.columns(n) has a property called Header1 that returns a reference to the Header object for that column. e.g.

 

Code:
oCol1 = grid1.columns(1)
oHeader = oCol1.header1
oHeader.caption = "This is Column 1"
Code:
proc page1_section1
    page1_section1 = createobject("page1_section1")
    page1_section1.addobject("mygrid", "grid")
    mygrid.addcolumn(1)
    oCol1 = mygrid.columns(1)
    oCol1.width=100
    oCol1.addobject("header1","header")
    oHeader = oCol1.header1
    oHeader.caption = "This is Column 1"

    mygrid.addcolumn(2)
    oCol2 = mygrid.columns(2)
    oCol2.width=100
    oCol2.addobject("header1","header")
    oHeader2 = oCol2.header1
    oHeader2.caption = "This is Column 2"
return page1_section1

Q:

Is there a way to prevent deleted items from showing on a grid.

A:

If SET DELETED is ON, then records that have been marked for deletion are ’invisible’


If the grid is set to “Double click to edit“, you can navigate the records in the grid using the mouse and/or the cursor/page keys as previously.

However, In Lianja 3.2 pressing “Return/Enter” switches the row into edit mode (and displays the record for editing in the split view Form if that is enabled).

While editing, pressing Ctrl+W or Esc in the “Form View” focuses back onto the grid.

 


Q:

How do I set up an SQL statement as a grid source? I can’t find any information on how to get this working.

Name: lianja grid with sql.jpg Views: 44 Size: 31.9 KB

A:

The grid does not adjust columns based on the SQL statement: they are set up in development mode only.

You can make columns non visible at runtime.

You can requery with an entirely new WHERE clause.

A2:

It’s more specific to desktop apps.

It is better to use Virtual Tables if you want to target web and/or mobile.

I’d really recommend going through the examples opening them up and then run them in web and mobile then you will see what can be accomplished with very little coding.

It’s important to realize that Lianja/VFP does not run in the browser but it can be used to generate dynamic content that is rendered in WebViews and DialogPanels.

The “client-side” delegates should be written in JavaScript.

You will find that the majority of VFP functions are available in the Lianja JavaScript framework.

You can play with these in the Web inspector | Console. Remember JavaScript is a case sensitive language.

A3:

 

you can use also a Custom VFP Section and use the “Browse” command.
Name: 2017-01-10 06_10_38-Rina - Dev.jpg Views: 43 Size: 70.4 KB

In this case, bsed on the menu choice, I browse a different table.
Name: 2017-01-10 06_11_09-Lianja App Builder v3.2.0 [sem_search] - UTF-8 - southwind - Licensed to Sof.jpg Views: 38 Size: 29.8 KB

You cau use the “setattr” to change the displayed table at runtime.

loFilter.setAttr(“browseCommand”, “browse noappend noactionbar noedit nodelete fields ” + lsBrowse + lsStyle)

Desktop client only. It’s VFP browse embedded in a page.


how to dynamically load data into forms and grids.

In LIanja 3.5 I have implemented the getJSON() and the setJSON(data) methods on sections in the Web and Mobile to simplify this.

You can dynamically query data using OData_Read() (or other means) and then load the form, canvas or grid section with the data. The setJSON(data) method for a grid is aware of the OData JSON format returned from OData_Read().

Name: Screen Shot 2017-05-31 at 2.14.08 PM.jpg Views: 92 Size: 96.6 KB

After loading a grid you can edit the rows of the grid as normal and save it..

You can always override navigation bar actions with custom actions and these can perform updates Server-side.

Also worth mentioning is that after setJSON(data) on a section, any related child sections and sidebars are refreshed automatically, so it operates in the same way as a standard section.


Q:

In one page, I have canvas section and grid section. Canvas section has 2 numeric fields and a command button.
Grid section had an empty table.
When user input 2 numbers, and click the command button, I insert into the table with the computed (var 1*var 2) but the grid does not refresh! I exit the App and view the table, the var was indeed inserted.
Any ideas to refresh the grid section dynamically?

A:

use (“section1”).refresh

A2:

I thought you wanted to create the grid “on the fly”.

If you do not need to edit the data, you can use a Web view, else you can use a Custom Fox Pro section and you can change the “command”

Name:  2017-05-15 09_13_21-Lianja App Builder v3.4.1 [dd_search] - UTF-8 - southwind - Licensed to Soft.jpg Views: 34 Size:  79.6 KB

browse noappend noactionbar noedit nodelete fields ORDERS__ORDERID :25 :H=”Campo Ordine”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders” ,”ORDERS__ORDERID”),ORDERS__ORDERID__sort :10 :C=”no,up,down”:H=”up/dn”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders”,”OR DERS__ORDERID__sort”),ORDERS__CUSTOMERID :25 :H=”Campo Cliente”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders “,”ORDERS__CUSTOMERID”),ORDERS__CUSTOMERID__so rt :10 :C=”no,up,down”:H=”up/dn”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders”,”OR DERS__CUSTOMERID__sort”),ORDERS__SHIPNAME :25 :H=”Campo Spedire a”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders”,”ORD ERS__SHIPNAME”),ORDERS__SHIPNAME__sort :10 :C=”no,up,down”:H=”up/dn”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders”,”OR DERS__SHIPNAME__sort”),CUSTOMERS__CONTACTNAME :25 :H=”Campo Rag. soc.”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders”,” CUSTOMERS__CONTACTNAME”),CUSTOMERS__CONTACTNAME__s ort :10 :C=”no,up,down”:H=”up/dn”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders”,”CU STOMERS__CONTACTNAME__sort”),ORDERS__ORDERDATE :25 :H=”Campo Data ordine”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders” ,”ORDERS__ORDERDATE”),ORDERS__ORDERDATE__sort :10 :C=”no,up,down”:H=”up/dn”:V=pageSearch_ValidFiltro(“{}”,”cur_Orders”,”OR DERS__ORDERDATE__sort”)style “* { selection-color:yellow; selection-background-color:black;font: bold 15px Arial; gridline-color:green; background:black;color:yellow;} QTableView::item {background:lightgreen; } QHeaderView::section { background-color:green;color:white;border:0px;font: bold 15px/30px Georgia, serif; } ”

 

 

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s