我能否repeater项目在JavaScript脚本方法算? [英] Can I get repeater item count in the javascript script method?

查看:115
本文介绍了我能否repeater项目在JavaScript脚本方法算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求。我在父视图UserControl和devex preSS按钮转发器。我打电话clientsideevents从按钮如下图所示:

I have one requirement. I have a repeater in the usercontrol and devexpress button in the parent view. I'm calling clientsideevents from the button like below:

    <dx:ASPxButton ID="btnNextStep" runat="server" Text="Proceed to Step 2" AutoPostBack="False" UseSubmitBehavior="False">

                        <clientsideevents click="function(s, e) {
                        { ToggleActive(); } }" />                            


                        <Image Url="~/next.png" />

      </dx:ASPxButton>

现在我希望把一些检查在ToggleActive()方法一样,如果中继器没有那么任何项目不应该进入下一个步骤,并显示一个警告像您不必在各个中继器的任何项目。我的问题是怎么样得到总项目数的JavaScript方法ToggleActive();

Now I want to put some check in the ToggleActive() method like if repeater doesn't have any item then it should not goes to next step and show an alert like you don't have any item in the respective repeater. My question is like how to get the total item count in the JavaScript method ToggleActive();

推荐答案

直放站呈现一个元素,这样你就可以找到 TR 算找到项目计数。

Repeater renders a table element so you can find the tr count to find the item count.

试试这个。

function ToggleActive(){
    //Change the table selector based on your markup that is rendered
    //Here I am using :gt(0) because first row will be header row
    if($("#repeaterId").find('tr:gt(0)').length > 0){
         //Do something
    }
    else{
         alert("You don't have any item");
    }
}

这篇关于我能否repeater项目在JavaScript脚本方法算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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