Possible solution for datagrid library errors

Bob Sneidar bobs at twft.com
Wed Nov 30 16:58:02 EST 2011


A slightly improved version:

on setTableColumns theDataGrid, theCardName
    if theDataGrid is empty then put "dgTableData" into theDataGrid
    if theCardName is empty then put the name of this card into theCardName
    put the customkeys of card theCardName into theKeyList
    
    -- if essential properties of the card do not exist, bail
    if not ("tblMaster" is in theKeyList) or not ("tblDisplay" is in theKeyList) then
        exit setTableColumns
    end if
    
    put the tblMaster of card theCardName into theTable
    put the tblDisplay of card theCardName into theColumnList
     
    if theColumnList is empty then 
        set the dgProp["columns"] of group theDataGrid to empty
        exit setTableColumns
    end if
     
    set the itemdelimiter to tab
    repeat for each line theLine in theColumnList
        put item 1 of theLine & comma after theColumns
        put item 2 of theLine & comma after theLabels
        put item 3 of theLine & comma after theWidths
    end repeat
     
    delete the last char of theColumns
    replace comma with return in theColumns
    delete the last char of theLabels
    replace comma with return in theLabels
    delete the last char of theWidths
     
    -- datagrid needs to be empty here or we will throw an error
    set the dgData of group theDataGrid to empty
    set the dgProp["columns"] of group theDataGrid to theColumns
    set the dgProp["column labels"] of group theDataGrid to theLabels
    set the dgProp["column widths"] of group theDataGrid to theWidths
end setTableColumns

Bob


On Nov 30, 2011, at 12:26 PM, Pete wrote:

> I've noticed a couple of posts recently related to changing the whole
> structure of a datagrid based on the type of data being displayed and I
> can't help feeling that's asking for trouble at some point (as Bob already
> discovered).
> 
> I'd like to throw out a couple of suggestions to handle this situation
> which I've implemented successfully.





More information about the Use-livecode mailing list