Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Telerik RadListBox:如何禁用特定项目的移动_Telerik_Listboxitem_Rad Controls_Radlistbox - Fatal编程技术网

Telerik RadListBox:如何禁用特定项目的移动

Telerik RadListBox:如何禁用特定项目的移动,telerik,listboxitem,rad-controls,radlistbox,Telerik,Listboxitem,Rad Controls,Radlistbox,如何在服务器端使用代码或在客户端使用javascript从左到右阻止特定项 例如:如果用户想将“阿根廷”从左向右移动,我想阻止并显示一条警告消息,说“这是不可能的” 请尝试使用下面的代码段 客户端 JS <script type="text/javascript"> function ClientTransferring(sender, args) { if (args.get_items().length > 0) { for

如何在服务器端使用代码或在客户端使用javascript从左到右阻止特定项

例如:如果用户想将“阿根廷”从左向右移动,我想阻止并显示一条警告消息,说“这是不可能的”


请尝试使用下面的代码段

客户端

JS

<script type="text/javascript">
    function ClientTransferring(sender, args) {

        if (args.get_items().length > 0) {
            for (var i = 0; i < args.get_items().length; i++) {
                if (args.get_items()[i]._element.textContent == "Argentina") {
                    args.set_cancel(true);
                    alert("your message comes here");
                }
            }
        }
    }
</script>
protected void RadListBoxSource_Transferring(object sender, RadListBoxTransferringEventArgs e)
{
    if (e.Items.Count > 0)
    {
        foreach (RadListBoxItem item in e.Items)
        {
            if (item.Text == "Argentina")
            {
                e.Cancel = true;
                //show your message from here
            }
        }
    }
}

如何将数据绑定到RadListBox?在这里,我们使用以下命令使用文本来标识项:'if(args.get_items()[i]。_element.textContent==“阿根廷”)'如果我想使用Id标识项,那么我们如何做?我在这里面临的另一个问题是,我只想停止从左到右传输项目,但即使在我尝试从右到左传输项目时,事件也会被触发……有没有解决方法的想法???@user3792804。。。。我知道很久以前有人问过这个问题,但e也包含e.DestinationListBox和e.SourceListBox。因此,如果e.SourceListBox=LeftHandListBox,那么您可以执行一个If-e.SourceListBox=LeftHandListBox,然后执行transfer-else e.cancel
<telerik:RadListBox runat="server" ID="RadListBoxSource" Height="200px" Width="230px"
    AllowTransfer="true" TransferToID="RadListBoxDestination" OnClientTransferring="ClientTransferring">
    <Items>
        <telerik:RadListBoxItem Text="Argentina"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Australia"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Brazil"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Canada"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Chile"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="China"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Egypt"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="England"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="France"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Germany"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="India"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Indonesia"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Kenya"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Mexico"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="New Zealand"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="South Africa"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="USA"></telerik:RadListBoxItem>
    </Items>
</telerik:RadListBox>
<telerik:RadListBox runat="server" ID="RadListBoxDestination" Height="200px" Width="200px">
</telerik:RadListBox>
<telerik:RadListBox runat="server" ID="RadListBoxSource" Height="200px" Width="230px"
    AllowTransfer="true" TransferToID="RadListBoxDestination" AutoPostBackOnTransfer="true"
        OnTransferring="RadListBoxSource_Transferring">
    <Items>
        <telerik:RadListBoxItem Text="Argentina"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Australia"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Brazil"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Canada"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Chile"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="China"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Egypt"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="England"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="France"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Germany"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="India"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Indonesia"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Kenya"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="Mexico"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="New Zealand"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="South Africa"></telerik:RadListBoxItem>
        <telerik:RadListBoxItem Text="USA"></telerik:RadListBoxItem>
    </Items>
</telerik:RadListBox>
<telerik:RadListBox runat="server" ID="RadListBoxDestination" Height="200px" Width="200px">
</telerik:RadListBox>
protected void RadListBoxSource_Transferring(object sender, RadListBoxTransferringEventArgs e)
{
    if (e.Items.Count > 0)
    {
        foreach (RadListBoxItem item in e.Items)
        {
            if (item.Text == "Argentina")
            {
                e.Cancel = true;
                //show your message from here
            }
        }
    }
}