Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

The only buttons in the action pane that should be enabled are those that perform valid actions for the current selection in the list. Buttons that cannot perform an action must appear in a disabled state. When the user changes the selection in the list, the enabled and disabled state of each button must be updated based on the new selection.

For example, you can use the Multiselect property to enable and disable an action pane button that performs an action on a single record. In some cases, the criteria for enabling and disabling an action pane button may be more complex, and must be done with code. The following procedure shows how to add code that enables and disables action pane buttons based on the selection in the list.

To enable or disable an action pane button

  1. In the AOT, expand Forms and find the form for the list page where the action pane button appears. Use the InteractionClass property of the form to get the name of the interaction class for the list page.

  2. Expand Designs, expand Design, and then expand the Action Pane. Get the name of each action pane button that you want to enable or disable based on the list selection.

  3. Expand Classes, right-click the interaction class for the list page, click Override Method, and then click selectionChanged. The Editor window opens and displays the selectionChanged method.

    Tip

    If you have to enable and disable several controls in the selectionChanged method, the code in the method can become difficult to implement and maintain. In this situation, you might want to add new methods to the list page interaction class that enable or disable specified action pane button controls. You could then use the selectionChanged method to call these methods.

  4. Use the list page activeRecord method to get a reference to the current record in the list page grid. To use the method, you have to supply the name of the data source for the list page.

    The following code example shows how to reference the current record in a grid that shows customer records. Notice the use of the queryDataSourceStr function to specify the name of the data source. In the example, CustTableListPage is the name of the query and CustTable is the data source of that query.

     
    Public void selectionChanged()
    {
    CustTable custTableCurrent = this.listPage().activeRecord(queryDataSourceStr(CustTableListPage, CustTable)); super();
    }
  5. Add the criteria that you use to enable or disable the action pane button.

    For example, you have a button in the action pane of a customer list page that you use to assign a credit limit to a customer. If the customer already has a credit limit, you want that button to appear as a disabled button. If the customer does not have a credit limit, you want that button to appear as an enabled button.

  6. Use the actionPaneControlEnabled method of the list page to enable or disable the button. To use the method, you specify the name of the button control and whether to enable or disable the control.

    The following code example shows how to enable or disable a specified action pane button. Notice the use of the formControlStr function to get the name of the button control. In the example, CustTableListPage is the name of the form and SetCreditMax is the name of action pane button.

     
    Public void selectionChanged()
    {
    CustTable custTableCurrent = this.listPage().activeRecord(queryDataSourceStr(CustTableListPage, CustTable)); super(); if(custTableCurrent.CreditMax > 0)
    {
    this.listPage().actionPaneControlEnabled(formControlStr(CustTableListPage, SetCreditMax), false); }
    else
    {
    this.listPage().actionPaneControlEnabled(formControlStr(CustTableListPage, SetCreditMax), true); }
    }
  7. In the Editor window, click Compile. Close the Editor window.

  8. http://msdn.microsoft.com/zh-cn/library/cc570334.aspx

最新文章

  1. reqwest请求api和约束(转载)
  2. BZOJ2683 简单题(CDQ分治)
  3. iOS CoreData relationship 中的inverse
  4. iOS 同一设备内的应用之间资源共享的实现
  5. 转:Beautiful Soup
  6. bzoj4716 假摔
  7. Spark是一种分布式的计算方案
  8. 使用 Attribute +反射 来对两个类之间动态赋值
  9. 三、Android NDK编程预备之Java jni入门创建C/C++共享库
  10. ActionBarSherlock的学习笔记(四) ------------ ActionBarSherlock中的搜索及SearchView的使用
  11. ARM-Linux S5PV210 UART驱动(2)---- 终端设备驱动
  12. algorithm@ Divide two integers without using multiplication, division and mod operator. (Bit Operation)
  13. ORACLE 11g R2数据库安装硬件环境要求
  14. CocoaPods 安装和使用
  15. Maven 版 JPA 最佳实践(转)
  16. h和.cpp文件的区别
  17. Flask -- 路由
  18. angular-file-upload 项目实践踩坑
  19. delphi开源JWT
  20. python+selenium二:定位方式

热门文章

  1. 自定义 404 与 500 错误页面,URL 地址不会重定向(一)
  2. C# 递归程序 获取某个节点下的全部子节点
  3. Handsontable 学习笔记-Methods
  4. 【高德地图开发4】---增加覆盖物setMapTextZIndex
  5. CMP指令(转)
  6. poj 2029 二维树状数组
  7. vijos P1037搭建双塔
  8. oracle 常用技巧及脚本
  9. html5技术介绍
  10. Eclipse+ADT+Android SDK 搭建安卓开发环境