`
uu008
  • 浏览: 8374 次
  • 性别: Icon_minigender_1
  • 来自: 西安
文章分类
社区版块
存档分类
最新评论

扩展easyui datagrid的两个方法.动态添加和删除toolbar的项(适用于1.3.0之后的版本)

阅读更多
(function ($) {
$.fn.my97 = function (options, params) {
if (typeof options == "string") {
return $.fn.my97.methods[options](this, params);
}
options = options || {};
if (!WdatePicker) {
alert("未引入My97js包!");
return;
}
return this.each(function () {
var data = $.data(this, "my97");
var newOptions;
if (data) {
newOptions = $.extend(data.options, options);
data.opts = newOptions;
} else {
newOptions = $.extend({}, $.fn.my97.defaults, $.fn.my97.parseOptions(this), options);
$.data(this, "my97", {
options : newOptions
});
}
$(this).addClass('Wdate').click(function () {
WdatePicker(newOptions);
});
});
};
$.fn.my97.methods = {
setValue : function (target, params) {
target.val(params);
},
getValue : function (target) {
return target.val();
},
clearValue : function (target) {
target.val('');
}
};
$.fn.my97.parseOptions = function (target) {
return $.extend({}, $.parser.parseOptions(target, ["el", "vel", "weekMethod", "lang", "skin", "dateFmt", "realDateFmt", "realTimeFmt", "realFullFmt", "minDate", "maxDate", "startDate", {
doubleCalendar : "boolean",
enableKeyboard : "boolean",
enableInputMask : "boolean",
autoUpdateOnChanged : "boolean",
firstDayOfWeek : "number",
isShowWeek : "boolean",
highLineWeekDay : "boolean",
isShowClear : "boolean",
isShowToday : "boolean",
isShowOthers : "boolean",
readOnly : "boolean",
errDealMode : "boolean",
autoPickDate : "boolean",
qsEnabled : "boolean",
autoShowQS : "boolean",
opposite : "boolean"
}
]));
};
$.fn.my97.defaults = {
dateFmt : 'yyyy-MM-dd HH:mm:ss'
};

$.parser.plugins.push('my97');
})(jQuery);

默认的用法和easyui的原生插件是一样的,可以通过class实例化,也可以通过代码实例化
1
<input  class="easyui-my97" type="text">

1
<input  id="my97" type="text" name="">
2
$('#my97').my97(options);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics