function getFirstAndLastMonthDay( year, month){
var firstdate = year + '-' + month + '-01';
var day = new Date(year,month,0);
var lastdate = year + '-' + month + '-' + day.getDate();//获取当月最后一天日期
//给文本控件赋值。同下
wisdom.find_text("<%=t_beginDate.ClientID %>").set_text(firstdate);
wisdom.find_text("<%=t_endDate.ClientID %>").set_text(lastdate);
}
//获取选中季度的第一天和最后一天
function getFirstAndLastQuarterDay(year,quarter)
{
if(quarter=="1")
{
var firstdate = year + '-' + 01 + '-01';
var day = new Date(year,3,0);
var lastdate = year + '-' + 03 + '-' + day.getDate();//获取当月最后一天日期
wisdom.find_text("<%=t_beginDate.ClientID %>").set_text(firstdate);
wisdom.find_text("<%=t_endDate.ClientID %>").set_text(lastdate);
}
if(quarter=="2")
{
var firstdate = year + '-' + 04 + '-01';
var day = new Date(year,6,0);
var lastdate = year + '-' + 06 + '-' + day.getDate();//获取当月最后一天日期
wisdom.find_text("<%=t_beginDate.ClientID %>").set_text(firstdate);
wisdom.find_text("<%=t_endDate.ClientID %>").set_text(lastdate);
}
if(quarter=="3")
{
var firstdate = year + '-' + 07 + '-01';
var day = new Date(year,9,0);
var lastdate = year + '-' + 09 + '-' + day.getDate();//获取当月最后一天日期
wisdom.find_text("<%=t_beginDate.ClientID %>").set_text(firstdate);
wisdom.find_text("<%=t_endDate.ClientID %>").set_text(lastdate);
}
if(quarter=="4")
{
var firstdate = year + '-' + 10+ '-01';
var day = new Date(year,12,0);
var lastdate = year + '-' + 12 + '-' + day.getDate();//获取当月最后一天日期
wisdom.find_text("<%=t_beginDate.ClientID %>").set_text(firstdate);
wisdom.find_text("<%=t_endDate.ClientID %>").set_text(lastdate);
}
}
function SetDefaultData(){
var planPeriod =wisdom.find_text("<%=t_planPeriod.ClientID %>").get_value();
var planQuaMon = wisdom.find_text("<%=t_planQuaMon.ClientID %>");
var result = new Array();
//为文本框重新赋值重置文本框中的内容
planQuaMon.reset_data(result, null, true, "name", "code");
switch (planPeriod) {
case "YEAR":
DisableWsdText('<%=t_planQuaMon.ClientID %>', true);
break;
case "QUARTER":
if(Global_Ctrl_Operation == wisdom.operate.opradd || Global_Ctrl_Operation == wisdom.operate.opredit ){
DisableWsdText('<%=t_planQuaMon.ClientID %>', false);
}
var obj1= new Object();
obj1.code = null;
obj1.name = "";
result.push(obj1);
for(var i=1;i<5;i++){
var obj= new Object();
obj.code = i.toString();
obj.name = "0"+ i.toString();
result.push(obj);
}
break;
case "MONTH":
var obj1= new Object();
obj1.code = null;
obj1.name = "";
result.push(obj1);
for(var i=1;i<13;i++){
var obj= new Object();
if(i<10){
obj.code = i.toString();
obj.name = "0"+ i.toString();
}
else{
obj.code = i.toString();
obj.name = i.toString();
}
result.push(obj);
}
if(Global_Ctrl_Operation == wisdom.operate.opradd || Global_Ctrl_Operation == wisdom.operate.opredit ){
DisableWsdText('<%=t_planQuaMon.ClientID %>', false);
}
break;
default:
DisableWsdText('<%=t_planQuaMon.ClientID %>', true);
break;
}
planQuaMon.reset_data(result, null, true, "name", "code");
}
setTimeout(function() { win.maximize();win.set_behaviors( Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close ); }, 100);设置弹出框的最大化和关闭按钮不可用。
function ClickExport(){//导出
var list;
var id =<%= wg_main.StrClientOprDetailName %>.id;
var planCode = <%= wg_main.StrClientOprDetailName %>.supEvaPlan_planCode;
if(wisdom.isEmpty(id)){
wisdom.alert("评估对象不能为空!");
return false ;
}
if(wisdom.isEmpty(planCode)){
wisdom.alert("评估计划编号不能为空!");
return false ;
}
var ajaxObj = new Object();
ajaxObj.CLSID = "Supplier";
ajaxObj.Method = "FormGenerator";
ajaxObj.LstStrParam = new Array();
var entity = new Object();
entity.orgCode = "<%=CurrentOrg.orgCode %>";
entity.bizOrgCode = "<%=CurrentBizOrg.bizOrgCode %>";
entity.id=id;
entity.planCode=planCode;
var strjson = objToJSONStr(entity)
ajaxObj.LstStrParam.push(strjson);
InvokeWsdAjaxRequest(ajaxObj, function(obj){
if (obj!= ""&&obj!=null) {
list=obj;
}
}, false);
if(list!=undefined&&list.id !=null)
{
DownLoadDoc(list.id);void(0);
}
}
在用InvokeWsdAjaxRequest方式实现方法时可以传整个实体对象,不过要先objToJSONStr(entity)这个实体,然后在.cs方法中用(string strJson)中先JsonUtility.DeserializeByNewton<FirstSupplyEvaluationFormDto>
//给文本框赋默认值
//给下拉框绑定数据
function DateBind() {
//先绑定年,年从2000开始到当前年+1,默认当前年
var year = wisdom.find_text("<%=Wsdyear.ClientID %>");
var yList = []; //年度的集合
var _Data = new Date();
var years = _Data.getFullYear() - 2000 + 1; //从2000到当前年的下一个年份有几个年份
for (var i = 2000; i < (years + 2000 + 1); i++) {
yList.push({ "text": i.toString(), "value": i.toString() });
}
year.reset_data(yList, "", true, "text", "value");
year.set_value(_Data.getFullYear()); //默认当前年
var month = wisdom.find_text("<%=Wsdmonth.ClientID %>");
//月的集合
var mList = [{ "text": "1", "value": "1" }, { "text": "2", "value": "2" }, { "text": "3", "value": "3" }, { "text": "4", "value": "4" }
, { "text": "5", "value": "5" }, { "text": "6", "value": "6" }, { "text": "7", "value": "7" }, { "text": "8", "value": "8" }
, { "text": "9", "value": "9" }, { "text": "10", "value": "10" }, { "text": "11", "value": "11" }, { "text": "12", "value": "12"}];
var _Data = new Date();
month.reset_data(mList, "", true, "text", "value");
month.set_value((_Data.getMonth() + 1)); //默认当月
js_doctrl_SetToolBarItemEnabledByValue("_SetOrderSearch", true);
<%=mainPanel.StrClientDisabledEditPanelFun %>(false);
}
总结上述结论,用js函数给空间赋默认值时需要用到控件.reset_data()方法,如果要为控件设置默认值就需要控件.set_value()这个方法。
下面看一下如何通过自己拼条件实现对数据的过滤:
function setDetailParams(sender,arg){
var entitylist = <%=wg_detailEdit.StrClientOprEntityList %>;
var idlist="" ;
if(entitylist != null && entitylist.length>0){
for(var i=0;i<entitylist.length;i++){
idlist +="'"+entitylist[i].template_id+"',";
}
idlist = idlist.substring( 0 ,idlist.length-1);
}
arg.vo = "SupplierEvaluationTemplateDto";
arg.advanceConditions = '[';
arg.advanceConditions += advanceCondition("","orgCode", "=", "{CurrentOrg.orgCode}","","and") + ',';
if(idlist.length>0){
arg.advanceConditions += advanceCondition("(","id", "not in {$0}", ""+idlist+"",")","and") + ',';
}
arg.advanceConditions += advanceCondition("","evaSystemId", "=", "'"+evaSystemId+"'","","and")+ ',';
arg.advanceConditions += advanceCondition("","supEvaTemplateStatus", "=", "'20'","","and")+ ',';
arg.advanceConditions += advanceCondition("","status", "<>", "'-1'","","");
arg.advanceConditions += ']';
arg.requestBizOrgs="-1";
}
<wsdGridCmdItemContext CurrentGridOperateMode="ShowModalWindow" IsShowAddAndDelete="true" >
<WsdGridOperateShowModalWindowInfo StrWinCloseCallback="detailCallBack" >
<AutoSearchDataProperty MulSelect="true" RequestBizOrgs="-1" ignorePermission="true" BeforeSearchClientScript="beforeSelectTem"
</AutoSearchDataProperty>
</WsdGridOperateShowModalWindowInfo>
</wsdGridCmdItemContext>
在<AutoSearchDataProperty >这个属性中BeforeSearchiInstantaneousShowClientScript这个属性指明了在弹出框之前过滤数据。BeforeSearchiInstantaneousShowClientScript="setDetailParams"这个函数属性。其中arg
注意:上面的很多属性只适用于公司的框架。