• How to refresh caller form


    Sometimes, We start out in the PurchTable form where we, by clicking a button, calls a class with the help of a menu item. The menu item has been given the datasource PurchTable.

    The called class updates the record that was selected in the PurchTable, but when this is done the user cannot see the changes without pressing F5 or restarting the form completely.

    The method FO_doRefresh() does a refresh on the PurchTable Form.
    In the called class we can easily get access to the caller object, and in this case we want to check if the caller is PurchTable and if the caller has the method FO_doRefresh(). If this is true, we will run the method to refresh the PurchTable form.


    The following code should be placed in the class after all the updates is completed.

        if(ClassIdGet(args.caller()) == ClassNum(SysSetupFormrun)
           && args.record().tableId  == tableNum(PurchTable))
        {
            if (formHasMethod(args.caller(),identifierStr(FO_doRefresh)))
            {
                args.caller().FO_doRefresh();
            }
        }

    The same principle applies to called forms and reports. The method FO_doRefresh on the PurchTable form contains the following code:

        void FO_doRefresh()
        {
        ;
            purchTable_ds.reread();
            purchTable_ds.refresh();
        }

    Personally I prefer doing everything in the class like this:

        if (args.record().isFormDataSource())
        {
            args.record().dataSource().refresh();
        }

    That way all the code is in 1 object and you avoid reflection to check if a method exists.

  • 相关阅读:
    这段时间的总结以及未来一个月的计划
    通过配置文件构建XML
    利用汇编实现表驱动
    Intel汇编语言程序设计课后习题,6.5.5
    盲目地相信网上评价未必是好事
    ObjectiveC基础语法复习笔记
    IOS6.0 学习第1篇,基础的IOs框架
    IOS6.0 学习第2篇,弹出AlertView
    Android Fragment的使用(1)
    ObjecteiveC 属性修饰符
  • 原文地址:https://www.cnblogs.com/Fandyx/p/2203727.html
Copyright © 2020-2023  润新知