Results 1 to 3 of 3

Thread: [Answers] Grid-1

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] Grid-1

    Q:
    graphical checkbox in a grid column
    A:
    Currently not supported. You can however put combo boxes in grids using Static or dynamic choicelists.

    Grid Column Attributes are accessed by double-clicking on the Grid Column Header. These Attributes then apply to the Column in the 'Grid View' and also in the 'Form View' when you are using a Split Grid.



    In the Lianja App Builder, you are probably used to the idea of double-clicking on a control or container's header or caption to access its Attributes and the same is true for a Grid Column:
    You might not know that you can also right-click on a Grid Column Header to display an additional menu of options:
    This gives you an alternative access to the Column's Attributes, the options to add a blank Column before or after the current Column and allows you to remove the current Column from the Grid.
    Remember you can add the Column back in if you change your mind, by dragging the field from the 'Column Names' in the Sidebar into the Grid and you can rearrange the Column order in the Grid by dragging a column by its header.



    Web Client Grid sections have a standard Save/Cancel/Add/Edit/Delete actionbar in the header unless the Grid itself is Readonly.



    You can call the grid.sort() method

    Code:
    oGrid = Lianja.get("page1.section1").grid
    // sort 3rd column ascending
    // columns start from 0
    // direction: 1=ascending, -1 = descending
    oGrid.sort(2,1)
    The Sort delegate is not currently called when clicking on the column headers.
    I'll check on support in JavaScript and the Web Client.



    Split Grids are normal Grid Sections with the ability to display a single record Form View within the Section. In the lianjademo App, the Orders and Order Details grids in the 'Customers Orders' dashboard are both Split Grids.
    You set Split Grid behaviour in the Grid Section Attributes, checking 'Double click to edit' and/or 'Split grid'.
    With 'Double click to edit' set, double-clicking on a Grid row displays a single record Form in the grid. If you have memo or object (e.g. image) fields, check the 'Show memo/object panel' attribute.



    Tip: hover your mouse over the join between the grid and the Form View to display a handle allowing your to resize the width of the Form View or hide it completely. There's also a resize handle for the height of the memo panel, just hover your mouse at the top of the panel header to reveal it.
    Checking 'Split grid' gives you three possible 'Views' for the grid and displays buttons in the grid header allowing you to switch between them.



    Split View:



    Form View:



    Grid View:



    ip: the displayed columns/fields are the same in the Form View as in the Grid View, i.e. a 'removed' column will not display in the Form View. They are also displayed in the same order - remember you can reorder the columns in a grid by dragging a column header over another.



    For a standard Grid Section, this appears to working fine:
    Code:
    Lianja.get("section2").refresh()


    Q:
    The Sort() method in the Grid takes 2 parameters nColumn, nDirection but where do they come from & how does it work?
    A:
    the number refers to the order of columns in a table, as displayed in the data manager. I haven't tried (yet) to use macros there, with a routine that would use afields() to get the order from the name. Give it a try!
    {fnum4fld("firstname"},{fnum4fld("lastname"}, etc.
    Note that the sort() nColumn argument (Column number) starts from 0 for the first column. There is also some information about the sort() indexing here.
    Also remember when you are manipulating a Grid Section with Lianja.getElementById() and synonyms, you need to work on the Section's embedded Grid object, e.g.
    Code:
    oGrid = Lianja.get("page1.section1").grid
    oGrid.sort(0,1)  // sort ascending on the first column


    Q:
    Code:
    proc Gamelist_grdGameList_dblclick()
            nRow=Lianja.Get("Gamelist.grdGameList").grid.activerow
            messagebox(str(nRow2))
    endproc
    A:
    Code:
    proc Gamelist_grdGameList_dblclick()
           oGrid = Lianja.Get("Gamelist.grdGameList").grid
           nRow = oGrid.activerow
           messagebox(str(nRow))
    endproc


    Q:
    Is it possible to access a grid column heading through code?
    For example, how do I determine the column heading for column 3?
    A:
    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"


    When you create a new grid object, make sure it is a 'mygrid' not a standard 'grid' or it will not have the colattribs() method defined.
    Code:
    ui_goalhomecont.addobject("ui_goalhomegrid", "grid")
    needs to be
    Code:
    ui_goalhomecont.addobject("ui_goalhomegrid", "mygrid")


    Q:
    How do I properly set this column to be read-only and have the grid functional?
    A:
    Code:
    oCol1 = ui_homegrid.columns(1)
    oCol1.readonly = .T.


    event that fires for a child grid as he moves through the parents. Parentdatachanged() fires before the new child is selected, so can't be used to pick up the child value (first row in child grid).
    The click() firing has been confirmed as expected behaviour - it shouldn't fire if you are clicking within the same row.



    Q:
    Code:
    ?Lianja.Get("test.section2").RowCount
    ?Lianja.Get("test.section2").item(1,2)
    A:
    Reference the grid contained by the Grid Section:

    Code:
    oGrid = Lianja.Get("test.section2").grid
    ? oGrid.rowcount
    ? oGrid.item(1,2)


    To get information from the Grid, or select a cell:

    Code:
    oGrid = Lianja.get("mypage.mysection").grid
    // what is the value at row 3, column 4
    ? oGrid.item(3,4)
    // what is the current row?
    ? oGrid.activerow
    // what is the current column?
    ? oGrid.activecolumn
    // select row 2, column 5
    oGrid.activatecell(2,5)


    Q:
    Have a section "section1", as grid, there's a test table in it.
    Another section "section2" as a canvas with a button on it.
    Code in button: lianja.get("section1").grid.add
    A:
    The grid is bound to the test table so all you need to do is append/insert a record in the table issue a refresh on the grid then position onto the new row using ...grid.goto( recno() ).



    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...ll=1#post12352
    This same topic is extended to another thread: http://www.lianja.com/community/show...Answers-Grid-2
    ...and another thread (dont ask why): http://www.lianja.com/community/show...Answers-Grid-3
    Last edited by josipradnik; 2016-10-24 at 03:26.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    Have a section "section1", as grid, there's a test table in it.
    Another section "section2" as a canvas with a button on it.
    Code in button:
    Code:
    lianja.get("section1").grid.add 
    A:
    You could also use
    Code:
    Lianja.get("section1").add
    Lianja.get("section1").refresh
    //or
    Lianja.showdocument("section:section1?action=add")
    Lianja.showdocument("section:section1?action=refresh")
    Then click on to the newly added record to populate any fields without defaults.



    Q:
    I'd like to read some values from a grid section eg. column 'firstname' from the currently active row. This should be easy to do once I have a reference to the grid, but this is where I am having trouble.
    Both below return some kind of object but accessing eg. loGrid.Recno gives 'Property/Variable 'RECNO' not found'. It does this for any property.
    Code:
    local loGrid = Lianja.get("Supplier.section1")
    local loGrid = Lianja.get("Supplier.section1").Grid //Is this is only for grid objects in custom sections?
    A:
    Try it without the 'local'

    "Lianja is data-centric"

    Grids are data bound. You can reference the actual data in the cursor as this is based on the active record as you move between records of the grid.
    Why futz about referencing grid cells when you can just work with the underlying data.
    Cursors are selected dynamically when refreshing each section. Pages are made up of sections. Sections can be data bound and have an underlying cursor.



    Q:
    in a grid section, I need to correct the value entered by user:
    eg:
    user type "Carry", I want to replace it with "Barry".
    How can I do it?
    In the validatation delegate of field "artcar.descrizione" I've put a function validCar('{}')
    In this function I do:
    Code:
    ValidCar(psValue)
    If psValue = "Carry"
      replace artcar.descrizione with "Barry"
    endif
    but not work... I've no error, but the value of the field is every "Carry"...
    A:
    Remember that the 'Set data mapping' can call a user defined function and your code determines the return value. e.g.
    Code:
    ValidCar(psValue)
    If psValue = "Carry"
      return "Barry"
    endif
    ..
    Or, use the Section Before or After data update to replace the field value when the row is saved.
    Validation is used to check and accept/reject the input value, displaying a message if the input is rejected.

    Q2:

    I need to perform a query to see if the text inserted from the user is correct, if not, I need to open a browse/rsp/form or other to simplify the user choice..
    in this case I've 3 value, but I can have a lot of value.. eg the item list.. or the vendor list..
    I can not use the "Section Before or After data update".. if I've more "controlled" field in the grid, I need to check one by one.
    A2:
    So put those operations in the user defined function for the Set data mapping.
    e.g. On the orders.customerid column, I specify:

    Set data mapping: p_val("{}")

    Code:
    //p_val.prg
    param p_typed
    ++ dmcount  // public memory variable initialized to 0
    if mod(dmcount,2) = 0
            m_chosen = p_typed
    else
            Lianja.showdialogpanel("Title","customerlist")
            m_chosen = customerid
            select orders
    endif
    return m_chosen
    // end

    (The check on the dmcount here prevents the showdialogpanel() being called a second time after a new value is returned.)
    I enter a value, here 'MILNE' and p_val() is called, firing up the Lianja.showdialogpanel() UI Page.



    I select a customer and the customerid is returned by p_val().



    The Validation is called after the Set data mapping - though I would think any validation should take place in the Set data mapping UDF in this scenario.
    Open the App Inspector to the Log tab and put this in your Validation UDF and you should see the call:
    Code:
    Lianja.writeLog("In validation")


    Q:
    for the grid navigation the issue is is that when the grid is not readonly and data fields are readonly, the user can still add new record or delete a record using the buttons (+) and (-). I think that this can cause troubles in the database with the risks of data manipulation when a grid is diplayed like that.
    Readonly option on a grid is a good option to prevent record deletion or addition.
    A:
    Why not uncheck the Show actionbar attribute on the section? If you are using keystrokes, PgUp, PgDn, Ctrl-Home and Ctrl-End provide alternatives to the navigation buttons in the actionbar.



    Q:
    I have a grid section and I want to move the cursor programmatic to refresh.
    Select mytable, seek or locate something, then call the refresh of the grid section, does nothing.
    Select mytable, goto 100 then call the refresh of the grid section, does nothing.
    grid.goto 100 don't work
    delegate section:grid1.section1?action=goto is not available.
    A:
    Set the activeRow property to position on a row relative to the grid
    Use the activeCell() method to position on a cell of the grid
    Use the goto() method to position on a specific record within the grid



    Q:
    I have a page1 with section1 with a grid in it.
    Section2 canvas section with a commandbutton. In the click event;
    I try to move the cursor in section1 and refresh the section grid;
    Tried seek, locate, goto, nothing works.
    Code:
    proc page1_section2_field1_click()
    Lianja.getElementByID("page1.section1").goto(500)
    Lianja.getElementByID("page1.section1").activerow( 500)
    Lianja.getElementByID("page1.section1").activecell (500,1)
    Lianja.getElementByID("page1.section1").refresh()
    endproc
    All four lines of code don't work
    I Tried;
    Code:
    select address
    go 500
    oGrid = Lianja.get("scout.log").grid
    lnActiveRow = oGrid.rowcount
    oGrid.refresh()
    oGrid.activatecell(lnActiveRow, 1)
    this don't work, but I think it's maybe a bug. It has something to do with pagination.
    If pagination=50 and I run this event, On screen it activates record 50.
    If pagination=250 and I run this event, On screen it activates record 250.

    A:
    You can only set the activeRow or activeCell in the current viewport. If you need to move outside of that then turn pagination off.
    Turn pagination off
    Use the grid.goto(500) method call



    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:
    you are confusing record numbers with rows in the grid. They are two completely different things.

    To move rows assign a value to the activeRow property. Goto() is for positioning on a record number that is in the grid data which it clearly may not be when using a filter to restrict the data displayed.



    Q:

    If I change data in a grid section's cell and hit 'enter', the change event doesn't fire although the database and grid have both been updated. This seems inconsistent because it means grid data can be changed (with the db updated) and if the user navigates away from that page, 'change' code would never run.
    Navigating to another row or clicking either the grid or page 'save' buttons causes the event to fire as expected.
    Oh, and out of interest I also looked at the datachanged and afterupdate events - afterupdate behaves as 'change' above and datachanged never fires.
    A:
    Datachanged is fired when you move between rows not when you edit the data. It's typically used to refresh sections manually based on the current record of the grid.
    It fires when the section is related.
    The cell is updated. The database is not until the row is flushed as Lianja uses row buffering.
    The record in the database is updated when you move off the row or force update it. If you move from one cell to another on the same row it is in the row buffer.

    in runtime mode with the App Inspector open. You can see the order of the events,
    There is no rowcolchanged delegate in grid sections.
    Moving between cells just updates the "dirty" buffer it does not dispatch any delegates nor does it update data in the database.

    Clicking the "Save" and "Revert" buttons works as it should so I do not know what you are doing for it not to work, unless you are moving off the record in a delegate.






    Q:
    If I look at the Grid object in the lianja docs it lists these events: afterRowColChange, beforeRowColChange, dragDrop
    and the Section Object list no events except the common ones.

    Now if I drag a grid section on to the page then I see some other event delegates, like change, after update etc. but not afterRowColChange and the others from the Grid object.
    So my question is: where can I get info about the events for a grid section, and where would one access the eg. 'afterRowColChange' (is this maybe only for a grid created in a custom section?)
    A:
    Grid sections are not exactly the same as grid objects in custom sections. Grid objects are there fir VFP 9 UI framework compatibility.


    Q:
    I added a grid section to one of my page, but the database and table sections are greyed out and blank.
    A:
    If you hold down shift and then click on a table, drag'n drop it onto a page, then the database and table will be populated. These are read only attributes.


    In v2.1 I have added several new section attributes for grids and attachment sections to handle dynamic grid row colors dependent on an expression. This is similar to dynamic cell colors for grid columns but affects the whole grid row. It is particularly useful when a grid is being refreshed at intervals and you want to hilite certain rows.

    Additionally...

    Grids and attachment sections now honor the "Pagination" attribute setting for grids in the web/mobile client so all rows fetched are loaded into the grid if pagination is off.



    Q:
    how calculated columns in a table are refreshed on a grid.
    Is the grid aware that the values are auto calculated or does there need to be refreshes in delegates?
    A:
    in the column attributes of the grid, there is a recalculate checkbox that handles what you mention.



    I had a situation where I wanted to populate a grid with a cursor that I had generated; allow the user to edit the data; and have data rules applied from the data dictionary.

    What I did was create a table that had a special field in it, cFilterExp C(36). When the user went to the page where that grid resided, I used guid() to create a guid, created the rows in the table which was shared by all users, put the guid() in the cFilterExp of each row, and set the filter of the section to that same guid() value. When the page was used with new data, a routine deleted the records from the table based on the old guid(), etc.

    I like working with tables/cursors much more than manually adding data to a grid, and having a real cursor gave me the ability to use dbf() to append the data to the real table. It was actually pretty efficient.



    Q:
    the way to properly replace grid fields with new grid data
    My grid is sourced to a data file. I do the updates in the data file and then a skip 0 and refresh of the grid.

    The specific code is as follows

    Code:
    Testlu1() &&testlkup8b() && &&LKUPL2('','L') &&DO LKUP2
    
    debugout MSTOCK
    debugout invdet.STOCK
    
    ENDI
    
    SELE (DETAIL2)
    
    REPLA stock with INV.stock,;
    invdet.unit with iif(invdet.unit=' ',iif(INV.unit=' ','EA',INV.unit),invdet.unit),;
    invdet.act with iif(EMPT(INV.act),MATCD,INV.act),invdet.COST WITH INV.COST
    SKIP 0
    GRID1.REFRESH
    DEBUGOUT INV.COST
    DEBUGOUT INV.RETAIL
    DEBUGOUT INV.UNIT
    
    debugout 'REPLACE'
    RETU
    The result is that the stock field which is the current grid field in focus when my valid is called gets updated but none of the other fields chg.
    A:
    Your replace is attempting to replace values in two different cursors (detail2 and invdet). Keep to one cursor target per replace statement.
    REPLACE is by cursor. Make it one or the other. If you remove the invdet. from the rest of the statement, then, it should work.
    you are not doing a skip 0 in the invdet cursor so the buffer is not being flushed.
    The following command will force write all dirty buffers:

    Code:
    flush
    //instead of skip 0


    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...p?2717-Answers
    This same topic is extended to another thread: http://www.lianja.com/community/show...Answers-Grid-2
    ...and another thread (dont ask why: I was young in thread editing): http://www.lianja.com/community/show...Answers-Grid-3

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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..

    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.
    Code:
    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 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
    Code:
    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:
    Code:
    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.

    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.

    In this case, bsed on the menu choice, I browse a different table.

    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().

    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"

    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; } "




    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...ll=1#post12352

    These answers are also systematized on the site "Lianja developer": https://lianjadeveloper.wordpress.com/category/grid/

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us