Thread Rating:
  • 385 Vote(s) - 2.82 Average
  • 1
  • 2
  • 3
  • 4
  • 5
修正したレコードだけを抽出したい
11-13-2013, 03:51 PM,
#2
RE: 修正したレコードだけを抽出したい
最初は、RecordModified を利用すればできるかな、と思っていたのですが、
RecordSet.batch-events? =true 時の修正はRecordModified が発生しないため、
不十分だということに気が付きました。

RecordsBulkChanges のフィールドで、変更が発生したレコードの一覧が取れるとうれしいのですが・・・。

もしアイディアをお持ちの方は教えてください。

Code:
{def fields:RecordFields =
    {RecordFields
        {RecordField "select", domain = bool, caption = "選択"},
        {RecordField "user-id", domain = String, caption = "番号"},
        {RecordField "First", domain = String, caption = "名前"},
        {RecordField "Last", domain = String, caption = "苗字"},
        {RecordField "Age", domain = int, caption = "年齢"},
        {RecordField "updated?", domain = bool, caption = "修正?"}
    }
}

{def rs =
    {RecordSet
        fields,
        {RecordData First = "John", Last = "Smith", Age = 25},
        {RecordData First = "Jane", Last = "Smith", Age = 29},
        {RecordData First = "Jane", Last = "Jones", Age = 28},

        {on e:RecordModified do
            {if-non-null rf =  e.field then
                {if rf.name != "select" then
                    set e.record["updated?"] = true
                }
            }
        }
    }
}

{def grid = {RecordGrid record-source = rs, height= 1in}}
{def modifiedgrid =
    {RecordGrid record-source = rs,
        filter = {RecordFilter.from-state  RecordState.modified}
        , height= 1in
    }
}
{def updated-grid =
    {RecordGrid record-source = rs,
        filter = {RecordFilter
                     {proc {r:Record}:bool
                         {return  r["updated?"] asa bool}
                     }
                 }
        , height= 1in
    }
}

{VBox
    "選択チェックボックスを操作しても、修正状態とは判断しない",
    {Table columns = 2,
        "元のレコード", grid,
        "カスタム修正フラグ[修正?(updated?)]を参照"    , modifiedgrid,
        "Record.stateを参照",updated-grid
    }
}


{CommandButton
    label = "一括変更",
    || RecordModified が発生しないため、カスタム修正フラグの値を変更できない
    {on Action do
        {with rs.batch-events? = true do
            {for r in rs do
                set r["Age"] = 100
            }
        }
    }
}


Messages In This Thread
RE: 修正したレコードだけを抽出したい - by umemura - 11-13-2013, 03:51 PM
Forum Jump:


Users browsing this thread:
2 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('1005')