Easyui Datebox extensions only show the month

Source: Internet
Author: User

It is normal for a date control to show only the month and year. However, Easyui Datebox does not support this format, or is to intercept the string, not desirable, I did not write a similar extension, but also is the implementation of the function, first of all to a picture bar

I can not write a level of advanced things, code, we are able to understand, but still contribute, let us make suggestions for common progress

$.extend ($.fn.combobox.methods, {
Yearandmonth:function (JQ) {
Return Jq.each (function () {
var obj = $ (this). ComboBox ();
var date = new Date ();
var year = Date.getfullyear ();
var month = Date.getmonth () + 1;
var table = $ (' <table> ');
var TR1 = $ (' <tr> ');
var tr1td1 = $ (' <td> ', {
Text: '-',
Click:function () {
var y = $ (this). Next (). HTML ();
y = parseint (y)-1;
$ (this). Next (). html (y);
}
});
Tr1td1.appendto (TR1);
var tr1td2 = $ (' <td> ', {
Text:year
}). appendTo (TR1);

var tr1td3 = $ (' <td> ', {
Text: ' + ',
Click:function () {
var y = $ (this). Prev (). html ();
y = parseint (y) + 1;
$ (this). Prev (). html (y);
}
}). appendTo (TR1);
Tr1.appendto (table);

var n = 1;
for (var i = 1; I <= 4; i++) {
var tr = $ (' <tr> ');
for (var m = 1; M <= 3; m++) {
var td = $ (' <td> ', {
Text:n,
Click:function () {
var yyyy = $ (table). Find ("Tr:first>td:eq (1)"). html ();
var cell = $ (this). html ();
var v = yyyy + '-' + (Cell.length < 2?) ' 0 ' + Cell:cell);
Obj.combobox (' SetValue ', V). ComboBox (' Hidepanel ');

}
});
if (n = = month) {
Td.addclass (' Tdbackground ');
}
Td.appendto (TR);
n++;
}
Tr.appendto (table);
}
Table.addclass (' mytable cursor ');
Table.find (' TD '). Hover (function () {
$ (this). addclass (' Tdbackground ');
}, function () {
$ (this). Removeclass (' Tdbackground ');
});
Table.appendto (Obj.combobox ("Panel"));

});
}
});


Call the method $ (' #id '). ComboBox (' Yearandmonth ')

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Easyui Datebox extensions only show the month

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.