• 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"]; 
        }
    }
  • 相关阅读:
    React 组件之间如何交流
    VMC INJECTION(开源JAVA模板框架)
    <th><td>表单用法
    弹性盒子
    骰子的布局(flex)
    javascript中的作用域
    js引用类型和基本类型、隐式类型转换以及强制类型转换面试题
    css的content属性,以及如何通过css content属性实现css计数器?
    CSS实现:一个矩形内容,有投影,有圆角,hover状态慢慢变透明
    百度元宵节动画
  • 原文地址:https://www.cnblogs.com/kainjie/p/3431236.html
Copyright © 2020-2023  润新知