zoukankan      html  css  js  c++  java
  • DEV checkbox PerformCallback实现级联 ,无刷新操作

    <%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ClientAPI.aspx.cs"
        Inherits="ASPxComboBox_ClientAPI" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentHolder" runat="Server">
        <script type="text/javascript">
        // <![CDATA[
            var lastCountry = null;
            function OnCountryChanged(cmbCountry) {
                if (cmbCity.InCallback() ) {
                    lastCountry = cmbCountry.GetValue().toString();
                    }
                    else { 
                        cmbCity.PerformCallback(cmbCountry.GetValue().toString());
                    }
            }
            function OnEndCallback(s,e){ 
                if (lastCountry){
                    cmbCity.PerformCallback(lastCountry);
                    lastCountry = null;
                }
            } 
        // ]]> 
        </script>
        <table class="OptionsTable">
            <tr>
                <td>
                    <dx:ASPxLabel runat="server" Text="Country:" ID="CountryLabel" AssociatedControlID="CmbCountry" />
                </td>
                <td>
                    <dx:ASPxComboBox runat="server" ID="CmbCountry" DropDownStyle="DropDownList" IncrementalFilteringMode="StartsWith"
                        DataSourceID="AccessDataSourceCountry" TextField="Country" ValueField="Country"
                        EnableSynchronization="False">
                        <ClientSideEvents SelectedIndexChanged="function(s, e) { OnCountryChanged(s); }" />
                    </dx:ASPxComboBox>
                </td>
                <td class="LeftPadding">
                    <dx:ASPxLabel runat="server" Text="City:" ID="ASPxLabel1" AssociatedControlID="CmbCity" />
                </td>
                <td>
                    <dx:ASPxComboBox runat="server" ID="CmbCity" ClientInstanceName="cmbCity" OnCallback="CmbCity_Callback"
                        DropDownStyle="DropDown" DataSourceID="AccessDataSourceCities" TextField="City"
                        ValueField="City" IncrementalFilteringMode="StartsWith" EnableSynchronization="False">
                        <ClientSideEvents EndCallback=" OnEndCallback"/>
                    </dx:ASPxComboBox>
                </td>
            </tr>
        </table>
        <asp:AccessDataSource ID="AccessDataSourceCountry" runat="server" DataFile="~/App_Data/WorldCities.mdb"
            SelectCommand="SELECT cr.Country, c.City as Capital FROM [Cities] c, [Countries] cr WHERE c.CityId = cr.CapitalId order by cr.Country">
        </asp:AccessDataSource>
        <asp:AccessDataSource ID="AccessDataSourceCities" runat="server" DataFile="~/App_Data/WorldCities.mdb"
            SelectCommand="SELECT c.City FROM [Cities] c, [Countries] cr WHERE (c.CountryId = cr.CountryId) AND (cr.Country = ?) order by c.City">
            <SelectParameters>
                <asp:Parameter Name="?" />
            </SelectParameters>
        </asp:AccessDataSource>
    </asp:Content>
    using System;
    using System.Data;
    using System.Web.UI;
    using DevExpress.Web.ASPxClasses;
    
    public partial class ASPxComboBox_ClientAPI : Page {
        protected void Page_Load(object sender, EventArgs e) {
            if (!IsCallback) {
                CmbCountry.Value = "Mexico";
                FillCityCombo("Mexico");
            }
        }
        protected void CmbCity_Callback(object source, CallbackEventArgsBase e) {
            FillCityCombo(e.Parameter);
        }
    
        protected void FillCityCombo(string country) {
            if (string.IsNullOrEmpty(country)) return;
    
            AccessDataSourceCities.SelectParameters[0].DefaultValue = country;
            CmbCity.DataBind();
    
            // Select the current country capital in the CmbCity
            DataTable table = ((DataView)AccessDataSourceCountry.Select(DataSourceSelectArguments.Empty)).Table;
            DataRow[] foundRows = table.Select(string.Format("Country = '{0}'", country)); 
            if(foundRows.Length > 0) 
                CmbCity.Value = (string)foundRows[0]["Capital"]; 
        }
    }
  • 相关阅读:
    pig实战 pig常用语法总结,教你快速入门——算法篇
    本科生码农应该会的6种基本排序算法(《数据结构与算法》)
    java 大块内存做数据缓存 大数据的高效收发
    一键安装zookeeper脚本制作篇 相关经验浅谈
    C语言第01次作业顺序、分支结构
    C语言 第三次作业函数
    hashmap笔记
    ArrayList排序与对象的序列化
    插入排序笔记(MIT算法导论课程)
    java解析四则运算表达式
  • 原文地址:https://www.cnblogs.com/kainjie/p/3431236.html
Copyright © 2011-2022 走看看