子网格:限制用户仅选择一个记录 [英] Subgrid: Restrict user to select only one record

查看:69
本文介绍了子网格:限制用户仅选择一个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在自定义实体表单上有一个子网格,其中我显示了案例实体的相关记录。我想限制用户只能选择一个记录。我如何在crm 2011中使用javascript来实现这一目标

i have a subgrid on a custom entity form where i am showing related records for Case Entity. I want to restrict user to select only one record. How can i achieve this using javascript in crm 2011

推荐答案

有时不支持!尤其是当需要全力以赴执行如此琐碎的UI请求时。
Subgird具有所有这些不错的方法,您可以使用它们,由于某些原因,Microsoft坚持不将其公开为SDK。真傻
我也会寻找一个javascript解决方案。这是一些可以帮助您完成任务的伪代码。 (未经测试,但它应该使您处于正确的轨道上)

Sometimes unsupported should be supported!!! Especially when one needs to go the whole distance to implement such trivial UI requests. The Subgird has all these nice methods that you can use that for some reason Microsoft insist on not exposing as SDK. That’s silly. I would also look for a javascript solution. Here is some pseudo code that can help you with the task. (not tested but it should put you on the right track)

该代码在内部crm网格控件上创建了一个简单的包装程序,并利用了其方法。

The code creates a simple wrapper on the internal crm grid control and utilizes its methods.

function xGrid(sId) {
    var o = this;
    o.Dom = document.getElementById(sId);

    if (!o.Dom) 
        return alret("this subgrid: " + sId + " is not on the form!");

    o.Grid = o.Dom.contorl;

    o.GetSelectedIds = function () {
            return o.Grid && o.Grid.get_selectedIds();
    }

    o.AddOnSelectionChange = function (fCallback) {
            o.Grid && o.Grid.add_onSelectionChange(fCallback);
            return o;
    }

}

当页面加载,即

function OnCrmPageLoad() {
    window.MyGrid = new xGrid("SubGrid_Test");
    MyGrid.AddOnSelectionChange(SubGridTestChanged);
}

并调用函数波纹管,然后选择内容会改变

And call the function bellow then the selection changes

function SubGridTestChanged() {
    if (MyGrid.GetSelectedIds().length > 1)
        alert("You’re only allowed to pick 1 record at a time");
} 

这篇关于子网格:限制用户仅选择一个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆