c#中如何不通过后台直接用js筛选gridview中的数据条件筛选查询?

js:

//条件筛选


var showstate = true;
function imagechange() {
if (showstate) {

$('#_toggle').hide(500, function () {
showstate = false;
image_logo.SetImageUrl("/Content/Images/01.png");
});
}
else {
$('#_toggle').show(500, function () {
showstate = true;
image_logo.SetImageUrl("/Content/Images/02.png");
});
}

}
function bt_select() {
//alert(cb_goodstype.GetValue());
updateGrid();
};

 

function updateGrid() {
var filterCondition = " 1=1 ";

var myDate = new Date();
//开始日期
// var end_s = ASPxDateEdit2.GetValue(); //获取今天的日期
// theDate = myDate.toLocaleDateString();
//获取控件选择的日期并进行转换
var star_s = cb_credate.GetValue(); //获取填写的日期
var star_y = new Date(star_s).getFullYear();
var star_m = new Date(star_s).getMonth() + 1;
// star_m = star_m < 10 ? ('0' + star_m) : star_m;
var star_d = new Date(star_s).getDate();
// star_d = star_d < 10 ? ('0' + star_d) : star_d;
var star_h = new Date(star_s).getHours();
var star_minute = new Date(star_s).getMinutes();
// minute = minute < 10 ? ('0' + minute) : minute;
// var star_dt = star_y + '/' + star_m + '/' + star_d + ' ' + star_h + ':' + star_minute;
var star_dt = star_y + '/' + star_m + '/' + star_d;

//结束日期
var end_s = cb_credate_2.GetValue(); //获取今天的日期
if (end_s == null) {
//end_s = myDate.toLocaleDateString();
var end_y = new Date(end_s).getFullYear();
var end_m = new Date(end_s).getMonth() + 1;
// end_m = end_m < 10 ? ('0' + end_m) : end_m;
var end_d = new Date(end_s).getDate();
//end_d = end_d < 10 ? ('0' + end_d) : end_d;
var end_h = new Date(end_s).getHours();
var end_minute = new Date(end_s).getMinutes();
// minute = minute < 10 ? ('0' + minute) : minute;
//var end_dt = end_y + '/' + end_m + '/' + end_d + ' ' + end_h + ':' + end_minute;
var end_dt = end_y + '/' + end_m + '/' + end_d;
}
else {
var end_y = new Date(end_s).getFullYear();
var end_m = new Date(end_s).getMonth() + 1;
// end_m = end_m < 10 ? ('0' + end_m) : end_m;
var end_d = new Date(end_s).getDate();
//end_d = end_d < 10 ? ('0' + end_d) : end_d;
var end_h = new Date(end_s).getHours();
var end_minute = new Date(end_s).getMinutes();
// minute = minute < 10 ? ('0' + minute) : minute;
//var end_dt = end_y + '/' + end_m + '/' + end_d + ' ' + end_h + ':' + end_minute;
var end_dt = end_y + '/' + end_m + '/' + end_d;
}

//订单编号
if (tb_orderno.GetValue() != null)

filterCondition += " and ([ORDERNO] like '%" + tb_orderno.GetValue() + "%') ";
//供应商
if (tb_peoname.GetValue() != null)

filterCondition += " and ([PEONAME] like '%" + tb_peoname.GetValue() + "%') ";

//买家
if (tb_buypoename.GetValue() != null)
filterCondition += " and ([BULLPEONAME] = '" + tb_buypoename.GetValue() + "') ";

//付款日期
if (cb_credate.GetValue() !=null)
filterCondition += " and [COLLDATE] >= #" + star_dt + "# and [COLLDATE]<= #" + end_dt + "#";
if (cb_credate_2.GetValue() != null)
filterCondition += " and [COLLDATE] >= #" + star_dt + "# and [COLLDATE]<= #" + end_dt + "#";

grid_MainOrder.ApplyFilter(filterCondition);

};

var text = new Array();
//获取radiobuttonlist中的text
function fn_GetRadioButtonListInfo() {
bt_select();
if (cb_credate.GetValue() != null) {
text[0] = cb_credate.GetValue();
};
if (cb_credate_2.GetValue() != null) {
text[1] = cb_credate_2.GetValue();
};
if (tb_orderno.GetValue() != null) {
text[2] = tb_orderno.GetText();
};
if (tb_peoname.GetValue() != null) {
text[3] = tb_peoname.GetText();
};
if (tb_buypoename.GetValue() != null) {
text[4] = tb_buypoename.GetText();
};
tokenbox.SetText(text.join(","));
};

var arrvalue = [];
function valuechanged() {
var filterCondition_1 = " 1=1 ";
arrvalue = tokenbox.GetValue().split(',');
for (var i = 0; i < arrvalue.length; i++) {
if (arrvalue[i] == cb_credate.GetValue()) {
filterCondition_1 += " and ([COLLDATE] = '" + cb_credate.GetValue() + "') ";
}
else if (arrvalue[i] == cb_credate_2.GetValue()) {
filterCondition_1 += " and ([COLLDATE] = '" + cb_credate_2.GetValue() + "') ";
}
else if (arrvalue[i] == tb_orderno.GetValue()) {
filterCondition_1 += " and ([ORDERNO] = '" + tb_orderno.GetText() + "') ";
}
else if (arrvalue[i] == tb_peoname.GetValue()) {
filterCondition_1 += " and ([PEONAME] = '" + tb_peoname.GetText() + "') ";
}
else if (arrvalue[i] == tb_buypoename.GetValue()) {
filterCondition_1 += " and ([BULLPEONAME] = '" + tb_buypoename.GetText() + "') ";
}

};
grid_MainOrder.ApplyFilter(filterCondition_1);

};

 <dx:ASPxFormLayout ID="ASPxFormLayout" runat="server" Width="100%">
                                            <Items>
                                                <dx:LayoutItem Caption="当前已选择">
                                                    <LayoutItemNestedControlCollection>
                                                        <dx:LayoutItemNestedControlContainer>
                                                            <dx:ASPxTokenBox runat="server" ID="tokenbox" Width="800px" TextField="chooseName" ValueField="chooseValue" ClientInstanceName="tokenbox">
                                                                <ClientSideEvents ValueChanged="valuechanged" />
                                                            </dx:ASPxTokenBox>
                                                        </dx:LayoutItemNestedControlContainer>
                                                    </LayoutItemNestedControlCollection>
                                                </dx:LayoutItem>
                                            </Items>
                                        </dx:ASPxFormLayout>
                                        <dx:ASPxFormLayout ID="ASPxFormLayout2" runat="server" Width="100%" ColCount="20">
                                            <Items>
                                                <dx:LayoutItem Caption="付款时间" ColSpan="5">
                                                    <LayoutItemNestedControlCollection>
                                                        <dx:LayoutItemNestedControlContainer>
                                                            <dx:ASPxDateEdit ID="cb_credate" runat="server" Width="100%" ClientInstanceName="cb_credate">
                                                                <ClientSideEvents ValueChanged="fn_GetRadioButtonListInfo" />
                                                            </dx:ASPxDateEdit>
                                                        </dx:LayoutItemNestedControlContainer>
                                                    </LayoutItemNestedControlCollection>
                                                </dx:LayoutItem>
                                                <dx:LayoutItem Caption="" ColSpan="5">
                                                    <LayoutItemNestedControlCollection>
                                                        <dx:LayoutItemNestedControlContainer>
                                                            <dx:ASPxDateEdit ID="cb_credate_2" runat="server" Width="100%" ClientInstanceName="cb_credate_2">
                                                                <ClientSideEvents ValueChanged="fn_GetRadioButtonListInfo" Init="function(s,e){ s.SetDate(new Date());}" />
                                                            </dx:ASPxDateEdit>
                                                        </dx:LayoutItemNestedControlContainer>
                                                    </LayoutItemNestedControlCollection>
                                                </dx:LayoutItem>
                                            </Items>
                                        </dx:ASPxFormLayout>
                                        <%--<dx:ASPxFormLayout ID="ASPxFormLayout7" runat="server" Width="100%" ColCount="10">
                                            <Items>
                                                <dx:LayoutItem Caption="是否允许配货" ColSpan="10">
                                                    <LayoutItemNestedControlCollection>
                                                        <dx:LayoutItemNestedControlContainer>
                                                            <dx:ASPxRadioButtonList runat="server" RepeatDirection="Horizontal" ID="cb_isgooutflag" IncrementalFilteringMode="StartsWith" DropDownStyle="DropDown" Width="245px" ClientInstanceName="cb_isgooutflag">
                                                                <ClientSideEvents ValueChanged="fn_GetRadioButtonListInfo" />
                                                                <Items>
                                                                    <dx:ListEditItem Text="不允许配货" Value="不允许配货" />
                                                                    <dx:ListEditItem Text="允许配货" Value="允许配货" />
                                                                </Items>
                                                                <Border BorderStyle="None" />
                                                            </dx:ASPxRadioButtonList>
                                                        </dx:LayoutItemNestedControlContainer>
                                                    </LayoutItemNestedControlCollection>
                                                </dx:LayoutItem>
                                            </Items>
                                        </dx:ASPxFormLayout>--%>
                                        <%--<dx:ASPxFormLayout ID="ASPxFormLayout3" runat="server" Width="100%" ColCount="10">
                                            <Items>
                                                <dx:LayoutItem Caption="金额范围" ColSpan="10">
                                                    <LayoutItemNestedControlCollection>
                                                        <dx:LayoutItemNestedControlContainer>
                                                            <dx:ASPxRadioButtonList runat="server" RepeatDirection="Horizontal" ID="money_list" IncrementalFilteringMode="StartsWith" DropDownStyle="DropDown" Width="50%" ClientInstanceName="money_list">
                                                                <ClientSideEvents ValueChanged="fn_GetRadioButtonListInfo" />
                                                                <Items>
                                                                    <dx:ListEditItem Text="小于 ¥10000" Value="小于10000" />
                                                                    <dx:ListEditItem Text="¥10000 至 ¥100000" Value="10000至100000" />
                                                                    <dx:ListEditItem Text="¥100000 以上" Value="100000以上" />
                                                                </Items>
                                                                <Border BorderStyle="None" />
                                                            </dx:ASPxRadioButtonList>
                                                        </dx:LayoutItemNestedControlContainer>
                                                    </LayoutItemNestedControlCollection>
                                                </dx:LayoutItem>
                                            </Items>
                                        </dx:ASPxFormLayout>--%>
                                        <dx:ASPxFormLayout ID="ASPxFormLayout1" runat="server" Width="100%" ColCount="10">
                                            <Items>
                                                <dx:LayoutItem Caption="订单编号" ColSpan="10">
                                                    <LayoutItemNestedControlCollection>
                                                        <dx:LayoutItemNestedControlContainer>
                                                            <dx:ASPxTextBox runat="server" ID="tb_orderno" ClientInstanceName="tb_orderno" Width="20%">
                                                                <ClientSideEvents ValueChanged="fn_GetRadioButtonListInfo" />
                                                            </dx:ASPxTextBox>
                                                        </dx:LayoutItemNestedControlContainer>
                                                    </LayoutItemNestedControlCollection>
                                                </dx:LayoutItem>
                                            </Items>
                                        </dx:ASPxFormLayout>
                                        <dx:ASPxFormLayout ID="ASPxFormLayout3" runat="server" Width="100%" ColCount="10">
                                            <Items>
                                                <dx:LayoutItem Caption="供&nbsp;应&nbsp;商&nbsp;" ColSpan="10">
                                                    <LayoutItemNestedControlCollection>
                                                        <dx:LayoutItemNestedControlContainer>
                                                            <dx:ASPxTextBox runat="server" ID="tb_peoname" ClientInstanceName="tb_peoname" Width="20%">
                                                                <ClientSideEvents ValueChanged="fn_GetRadioButtonListInfo" />
                                                            </dx:ASPxTextBox>
                                                        </dx:LayoutItemNestedControlContainer>
                                                    </LayoutItemNestedControlCollection>
                                                </dx:LayoutItem>
                                            </Items>
                                        </dx:ASPxFormLayout>
                                        <dx:ASPxFormLayout ID="ASPxFormLayout4" runat="server" Width="100%" ColCount="10">
                                            <Items>
                                                <dx:LayoutItem Caption="买&nbsp;&nbsp;&nbsp;&nbsp;家&nbsp;&nbsp;" ColSpan="10">
                                                    <LayoutItemNestedControlCollection>
                                                        <dx:LayoutItemNestedControlContainer>
                                                            <dx:ASPxTextBox runat="server" ID="tb_buypoename" ClientInstanceName="tb_buypoename" Width="20%">
                                                                <ClientSideEvents ValueChanged="fn_GetRadioButtonListInfo" />
                                                            </dx:ASPxTextBox>
                                                        </dx:LayoutItemNestedControlContainer>
                                                    </LayoutItemNestedControlCollection>
                                                </dx:LayoutItem>
                                            </Items>
                                        </dx:ASPxFormLayout>
                                    </div>
                                    <dx:ASPxHiddenField ID="hiden_01" runat="server"></dx:ASPxHiddenField>
View Code

 

posted @ 2015-12-27 15:36  小鹿的无名书  阅读(865)  评论(0编辑  收藏  举报