Results 1 to 3 of 3

Thread: [Answers] Grid-2

Threaded View

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

    [Answers] Grid-2

    Q:
    May I know if I can add a command button in a column of a grid so that user can click on it to popup a form for data entry
    A:
    The grid section is comprised of columns.
    Double click on the column header to slide in the column attributes.
    A column has a wide range of attributes including the ability to display as a "Button", a "Hyperlink" or a "Custom Control".



    Then in the Grid section attributes add your delegate for "Link Clicked".





    any grid section filters that have {...} macros in them, these are expanded at the time of refreshing the grid. This basically means that the filter itself is dynamically evaluated at the time the grid is refreshed. This works in all views; desktop, web and mobile.



    A grid is bound to data so IOW there is a corresponding cursor for each grid.
    As you navigate records in the grid the active record in the underlying cursor is changed.
    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.



    If you make the grid "readonly" it will be highlighted.
    Otherwise
    Code:
    Lianja.get("page1.section2").grid.activeRow = 0


    The grid is bound to your data which I understand to be a SQL query so you can update the data and refresh the grid (saving the activerow and positioning back on it).

    The ROWID for the base table is a hidden column that you can use to perform the update.
    Look in the console and LIST STATUS to see what cursor is bound to your grid them SELECT cursorname and issue a ? rowid. That is the record in the base table that needs updated.



    You need to use the doScroll() method like this if you want to move down the rows of the grid.
    Code:
    Lianja.get("clock_records.list").grid.doScroll( arg )
    Note that Lianja.get() does not require "page:", you are looking up the object.



    Q:
    I tried the SQL with filter as follows but the grid always show all records
    SQL :
    select * from ventlrec
    Filter :
    where clernoee="{peoplekiosk.emp_no}"
    A:
    The filter is a condition. Remove the where.
    A better way to achieve this would be to apply the whole sql select ... Where ...
    What data type is clernoee? If it's not a char column remove the quotes.



    Q:
    I have a desktop app with a page with one grid section
    I have set the "Filter" attribute to as follows for top grid section :
    clernoee="{peoplekiosk.emp_no}"
    A:
    What is "peoplekiosk"? If it is a namespace perhaps it is not declared until later.
    Setting a filter on a large number of records is also not a good idea.
    Better to have an index key on it and restrict by the index key.
    You do not say if this is a table, SQL statement or Virtual Table.
    Setting filters to variables requires the grid to be manually refreshed programmatically when you change the variable.

    If the grid is not editable use SQL statement.
    If it is editable use a Virtual Table.
    Look at the Virtual Tables example and you will see how {...} macros are used in the "where" condition of the SQL statement.



    Added the ability for a grid section to have "Multi Select Rows". This displays a checkbox column for each row. As the user clicks a checkbox, the "selectionChanged" delegate is called with a comma separated list of values. These values are determined by the "Multi Select Row Expression" e.g. You can multi select rows in a grid and then call your own business procedure to handle app specific business logic



    And these are the attributes you need to set for the grid section to enable this functionality.



    The "selectionChanged" delegate itself looks like this.

    Code:
    ////////////////////////////////////////////////////////////////
    // Event delegate for 'selectionchanged' event
    proc page1_section2_selectionchanged(arg)
        // 'arg' is a comma separated list of items selected
        // It can be used directly to load the selected items into a ListBox
        Lianja.writeOutput("selectionChanged() arg="+arg)
    endproc


    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-3
    Last edited by josipradnik; 2016-10-24 at 03:26.

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