FineUI 官方论坛
标题:
老版本的ExtAspNet如果在js中获得控件的值
[打印本页]
作者:
yc2018nian
时间:
2018-4-19 10:23
标题:
老版本的ExtAspNet如果在js中获得控件的值
请问各位大神,我这里的一个项目使用的是老版本的ExtAspNet,现在需要用js获取控件的值,但是使用Ext.getCmp('<%=ddlProduction.ClientID%>').getValue()时提示Ext.getCmp(...) is undefined ,用尽了各种办法还是无法获取控件的值,请问该怎么才能获取啊
作者:
sanshi
时间:
2018-4-19 11:23
Ext.getCmp(...) is undefined应该是说这个控件找不到,把完整代码发出来看下
作者:
yc2018nian
时间:
2018-4-19 12:32
本帖最后由 yc2018nian 于 2018-4-19 12:36 编辑
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FaultByDay.aspx.cs" Inherits="NanCheRailWayWeb.Web_DataManage.FaultByDay" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script src="../js/lockscreen.js" type="text/javascript"></script>
<script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../js/chart/highcharts.js" type="text/javascript"></script>
<script src="../js/chart/exporting.js" type="text/javascript"></script>
<script src="../js/chart/dark-green.js" type="text/javascript"></script>
<script src="../js/echarts-all.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext: PageManager ID=" PageManager1" runat="server" AutoSizePanelID="Toolbar" />
<ext:Toolbar ID="Toolbar" runat="server">
<Items>
<ext: Label ID="Label5" runat="server" Label="Label" Text="开始时间:">
</ext: Label>
<ext: DatePicker ID="dpStartDate" runat="server" Label="Label" EnableDateSelect="true">
</ext: DatePicker>
<ext: Label ID="Label6" runat="server" Label="Label" Text="结束时间:">
</ext: Label>
<ext: DatePicker ID="dpEndDate" runat="server" Label="Label" EnableDateSelect="true">
</ext: DatePicker>
<ext: Label ID="Label1" runat="server" Label="Label" Text="车型:">
</ext: Label>
<ext: DropDownList runat="server" ID="ddlTrainModel" Label="车型" Width="100px" AutoPostBack="True"
OnSelectedIndexChanged="ddlTrainModel_SelectedIndexChanged">
</ext: DropDownList>
<ext: Label ID="Label7" runat="server" Label="Label" Text="生产形式:">
</ext: Label>
<ext: DropDownList runat="server" ID="ddlProduction" Label="生产形式" AutoPostBack="true"
Width="100px" OnSelectedIndexChanged="ddlProduction_SelectedIndexChanged">
</ext: DropDownList>
<ext: Button ID="btnSearch" runat="server" Text="查询" IconUrl="../images/03.png"
EnablePostBack="false" CssStyle="background:url(../images/search.jpg) no-repeat">
</ext:Button>
<ext:Button ID="btnExport" Text="导出Excel" ValidateForms="extForm1" runat="server"
Icon="SystemSaveNew" EnableAjax="false" DisableControlBeforePostBack="false">
</ext:Button>
<ext: TextBox ID="testText" runat="server" Label="Label" Text="测试:">
</ext: TextBox>
</Items>
</ext:Toolbar>
<div id="faultDiv" style="width: 95%; margin: 0 auto; height: 600px;"></div>
</div>
</form>
</body>
</html>
<script type="text/javascript">
var faultDiv;
function Fault() {
faultDiv = echarts.init(document.getElementById('faultDiv'));
var faultOption = {
title: {
text: '按天统计故障数量'
},
tooltip: {
show: true,
trigger: 'item'
},
legend: {
show: true,
data: ['故障数量'],
padding: 15
},
dataZoom: {
show: true,
realtime: true,
start: 0,
end: 20
},
xAxis: [{
type: 'category',
name:'日期',
data: [" "]
}],
yAxis: [{
type: 'value',
name:'故障数量'
}],
series: [{
name: '故障数量',
type: 'line',
itemStyle: {normal: {color:'#9BCA63'}},
data: [" "],
markLine:{
data:[{
type: 'average',name:'平均值'
}]
}
}]
};
faultDiv.setOption(faultOption);
SetFaultData();
}
function SetFaultData() {
var riqi = [<%=GetFaultdataX()%>];
var num = [<%=GetFaultdataY()%>];
var options = faultDiv.getOption();
options.xAxis[0].data= riqi;
options.series[0].data= num;
faultDiv.setOption(options);
faultDiv.refresh();
}
$(function () {
var text1 = '<%=testText.ClientID %>'
var trainModel = Ext.getCmp(text1).getValue();
alert(trainModel);
Fault();
})
</script>
作者:
yc2018nian
时间:
2018-4-19 13:21
上边就是代码了.请大神看看怎么回事,谢谢
作者:
shihahayue
时间:
2018-4-19 17:10
本帖最后由 shihahayue 于 2018-4-19 17:20 编辑
在这写Ext.ready(function(){ 或者 onReady 不是 $(function () {
作者:
yc2018nian
时间:
2018-4-19 18:17
我之后已经发现这个问题了,也要把一开始引用的jquery.js取消掉,然后里边用Ext的方法,不能用jquery的,虽然已经解决了,还是谢谢各位了.感谢!
欢迎光临 FineUI 官方论坛 (https://fineui.com/BBS/)
Powered by Discuz! X3.4