Results 1 to 2 of 2

Thread: [Answers] Grid-3

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

    [Answers] Grid-3

    Q:
    Is there an attribute I can set to create a column calculation such as sum or average, etc?
    A:
    Grid column subtotals were added in Lianja v1.1.3. You can perform both horizontal and vertical totaling using NoCode.







    You can hide and show a grid section dynamically using Lianja.getElementByID("page1.section1").hide() or show().



    In the v1.3 release I have implemented "MultiSelect rows" for grids.
    There are two new attributes for grid and attachment sections.
    "MultiSelect rows"
    and
    "MultiSelect row expression"
    Together with a new delegate called "SelectionChanged".
    If you check "MultiSelect rows" in the grid section attributes then the first column of the grid contains a checkbox for each row. Clicking the checkbox calls the "SelectionChanged" delegate passing it a comma separated list of items that are evaluated for each row selected based on the "MultiSelect row expression".
    This provides the ability to select multiple rows in a grid then perform an operation on them (section menu of other action) such as send an email or delete the records, then refresh the grid.



    In v1.2.4 I have added the ability to dynamically sort the data displayed in a grid by clicking on the grid column headers. This is implemented in both desktop and web clients. There is a new grid section attribute "Sortable" which you can check to enable this on a grid.
    Here is an example in the Web Client. Just click the column header once to sort ascending and again to sort descending. This is all handled automatically for you and the grid is refreshed while still maintaining the parent->child relationship, filters and search condition if active.



    To make a grid "Sortable" just check the "Sortable" attribute in the section attributes,





    Q:
    I am struggling to find info on this, my grid has Price and Quantity columns and I want to add a Total column:
    1. Must I have a db column that is marked as calculated? if so, does this column need to be created in code because I don't see anything in the ide column editor to indicate that the column is calculated.
    2. If I don't have a calculated db column, can I just have a column grid column? if so, where do I enter the formula?
    I guess I may need something like PRODUCT.PRICE*PRODUCT.QUANTITY in 'Get Data Mapping' but that has no effect.
    A:
    Just add a column and put the expression as the data source.
    Set other columns that affect this new "calculated" column to "Recalculate" and its all done for you.
    The "Grid formatting" example App demonstrates this.



    Q:
    We can change the RecordSource of a grid no problem but removing the columns & starting again seems more difficult.
    we can use ogrid.removecolumn(ColumnNo) in a loop to remove the columns but when the RecordSource is changed to a new value, the original columns headers & number of columns return.
    How can we get the grid to re-read the column headers in the way that happens when the grid is first created?
    A:
    Then try clear() on the grid.



    Q:
    In our app (at the customers request), we have 14 grid gadgets in 7 form sections (2 per section), populated by 14 READWRITE SQL cursorsA
    The prg does the SQL & all works fine. The cursors are populated. Logic for the grids, called at each pass through the logic, is :
    Code:
    SELECT * from xxx WHERE xxx INTO CURSOR zzz READWRITE
    oGrid = Lianja.Get("Page.section").GadgetGrid
    oGrid.RecordSourceType = 4
    oGrid.RecordSource = "zzz"
    oGrid.Refresh()
    The SQL always produces data for each cursor.
    All of the above is so simple and works beautifully SOMETIMES. Sometimes the grids work great, sometime some of them are blank, sometimes they are not. Sometimes they the blank ones are populated & sometimes the populated ones go blank. This is ridiculous.
    These grid gadgets really only want tables and when they are blank they error by saying no such table. We have tried every permutation of RecordSourceType and RowSourceType.
    A:
    yes I do understand the way VFP devs like using cursors like that but that does not work web/mobile client/server so I'll look and see what you are doing first.
    There should be no issue with Lianja closing cursors unless you are selecting into the same cursor name in which case it behaves just like VFP.
    it seems that what you want to do is choose multiple items in a list by checking the checkbox in the first column.
    what happens as you do that? Does that cause you to perform a query on another grid? Then iterate this process on the child grids...?
    i think this is where the design needs looked at.
    what you need is a top level parent form e.g. Job#
    this then relates to the child table that has records added to it for the job. This then will work multiuser and in the web / mobile.
    The trick is to add all the related child records when you create a new job# or proposal# and these can be done in an insert trigger. They are related by job# so you have one child table with all the multiple choices as records.
    This is then properly relational and can be properly queried by "joining" the tables together and displaying the related data in the UI.
    this will allow you to design the app as form -> grid -> grids and the Lianja engine will do all the heavy lifting.
    and all that will work in web/mobile.



    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-1
    ...and another thread (dont ask why): http://www.lianja.com/community/show...Answers-Grid-2
    Last edited by josipradnik; 2016-10-24 at 03:28.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    remove a column in grid section
    A:
    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.



    Q:
    Code:
    ALTER TABLE "test" MODIFY CONSTRAINT AMOUNT SET CHECK(between(Amount,100,200))
    ALTER TABLE "test" MODIFY CONSTRAINT AMOUNT SET ERROR "Error, amount must be between 100 and 200"
    No error,
    I did check it on the table and it's correct.
    when input in the table, it won't display the errortest after wrong input, the check itself works correct.
    It works when I place the field in a textbox.
    It doen't work in a browse or grid.
    A:
    Grids do not currently 'Inherit dictionary rules' - Form and Canvas Sections can (off by default, check the Attribute to enable).
    Your validation check will be evaluated when the data is saved to the table and the update rejected if the validation fails, but the error message will not be shown in the Grid.



    Next() and previous() are for skipping pages of records. Your grids don't have pages of records as you have pagination off.



    you don't need to refresh the whole grid you can just refreshRecno( nRecno) which you obtain just like you did with rowid but reference recno instead.



    Q:
    can i use cursor in to a grid section
    A:
    A dynamic grid like that which is not bound to a fixed data source cannot be related from a parent section or have child sections as it is not constant.
    So if you want to dynamically have a grid on a dynamically chosen table or query then use a custom section.
    If you take a look at the canvas demo example it shows you how to do that without using a temporary table. You can just add rows to the grid and recalc subtotals and grand totals.



    (?A):
    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 grid is read only.
    I plan to move through the grid and edit any record I select in it, in the Edit Grid section.
    Clicking any row in the grid shows the record in the Events Edit section as expected.
    However I can't move through the grid using the cursor keys on the keyboard. i.e Focus doesn't move from the selected row.
    A:
    If you uncheck the Readonly for the Grid Section then make the Columns in the Grid Reaonly (double-click the Column header to open the Attributes), you will be able to use the cursor keys to move between rows in the Grid.
    The editable Grid + readonly columns will only give you cursor movement in the Desktop Client, not in the Web Client. Grid Sections in the Web Client (and Desktop Client) respond to touch and mouse/touchpad movement and clicks.



    Q:
    If you create a hyperlink for items in a grid, how do you link clicks on that item to open another page/report and go to that record?
    A:
    With the 'Hyperlink' Attribute of a Grid Section Column checked to True (double-click the Column Header to access the Attributes), the containing Grid Section 'Link Click' event delegate is called when the link is clicked. The event delegate is passed two parameters: the 'Data source' of the Column and the value of the clicked cell.
    Lianja.showDocument() can be used for actions such as selecting another Page, searching for a value using the Page Search field etc.
    For the Lianja Web Client, the link value will need to be unique to be able to identify the record in the 'Link Click' event delegate.



    "Cell dynamic background" and "Cell dynamic foreground" are not currently supported on the Lianja Web Client.
    On the Desktop Client, they are not exposed as properties, but the attributes take an expression. This could be a comparison to a memory variable or other data or you can specify a Lianja/VFP UDF (user defined function) that returns the color, e.g. for a character column value:
    myfunc("{}")
    Your myfunc.prg or myfunc function in a library is passed the current cell value and can then do any processing or checks required before returning the color. Calling the section.refresh() will re-evaluate the expressions in the attributes.

    The Canvas Section grid/TreeGrid is based on the Tree class rather than the Grid Section and does not have "Cell dynamic background" and "Cell dynamic foreground".

    It does have the option of specifying an icon on the row - maybe this would work for you as an alternative?

    In the screenshot below, I've used the lianjacustomcanvas App and specified an icon at the start of the row in the Cart, changing the icon depending on the Cart item's total.

    Note: Desktop App





    Q:
    In a page I've a custom section, with only one textbox (textboxa) and a grid section, based on a table (tableA).

    In the "change" delegate of "textboxa" I wrote:
    Code:
    select tableA
    append blank
    replace field1 with "jjj", field2 with "ggg" etc.

    in the grid, I see only blank record...
    like as the "commit" rewrite my field...
    if I remove the gridsection, all work fine...
    A:
    Try a
    Code:
    skip 0

    after the replace line.








    When I press "Enter" I insert a record in the third grid "Game Log", the lower one, and update even the score in the second (that of Set).
    When I do a refresh of the second (SET, to refresh the score), the third grid will always show me the Log of the first set .. even if they are on the second or third ..
    A:
    You should be able to use grid.activerow and grid.activatecell when you refresh the Grid Section, e.g.:

    Code:
    oGrid = Lianja.get("scout.set").grid
    lnActiveRow = oGrid.activerow
    oGrid.refresh()
    oGrid.activatecell(lnActive Row, 1)


    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-1
    ...and another thread (dont ask why): http://www.lianja.com/community/show...Answers-Grid-2
    Last edited by josipradnik; 2016-10-24 at 03:28.

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