- 论坛徽章:
- 0
|
datagrid扩展editor
easyui1.2.4支持了数据编辑功能,但提供的东西有限,所以需要自己进行扩展。下面是扩展一个datetimebox的编辑器。
Js代码- 1.$.extend($.fn.datagrid.defaults.editors, {
- 2. datetimebox: {//datetimebox就是你要自定义editor的名称
- 3. init: function(container, options){
- 4. var input = $('<input class="easyuidatetimebox">').appendTo(container);
- 5. return input.datetimebox({
- 6. formatter:function(date){
- 7. return new Date(date).format("yyyy-MM-dd hh:mm:ss");
- 8. }
- 9. });
- 10. },
- 11. getValue: function(target){
- 12. return $(target).parent().find('input.combo-value').val();
- 13. },
- 14. setValue: function(target, value){
- 15. $(target).datetimebox("setValue",value);
- 16. },
- 17. resize: function(target, width){
- 18. var input = $(target);
- 19. if ($.boxModel == true){
- 20. input.width(width - (input.outerWidth() - input.width()));
- 21. } else {
- 22. input.width(width);
- 23. }
- 24. }
- 25. }
- 26.
- 27. });
- $.extend($.fn.datagrid.defaults.editors, {
- datetimebox: {//datetimebox就是你要自定义editor的名称
- init: function(container, options){
- var input = $('<input class="easyuidatetimebox">').appendTo(container);
- return input.datetimebox({
- formatter:function(date){
- return new Date(date).format("yyyy-MM-dd hh:mm:ss");
- }
- });
- },
- getValue: function(target){
- return $(target).parent().find('input.combo-value').val();
- },
- setValue: function(target, value){
- $(target).datetimebox("setValue",value);
- },
- resize: function(target, width){
- var input = $(target);
- if ($.boxModel == true){
- input.width(width - (input.outerWidth() - input.width()));
- } else {
- input.width(width);
- }
- }
- }
- });
复制代码 自己测试过的代码
Js代码- 1.$.extend($.fn.datagrid.defaults.editors, {
- 2. datetimebox :{
- 3. init: function(container, options){
- 4. var input = $('<input class="easyuidatetimebox">').appendTo(container);
- 5. return input.datetimebox();
- 6. },
- 7. getValue: function(target){
- 8. return $(target).datetimebox("getValue");
- 9. },
- 10. setValue: function(target, value){
- 11. $(target).datetimebox("setValue",value);
- 12. },
- 13. resize: function(target, width){
- 14. var input = $(target);
- 15. if ($.boxModel == true){
- 16. input.width(width - (input.outerWidth() - input.width()));
- 17. } else {
- 18. input.width(width);
- 19. }
- 20. }
- 21. }
- 22. });
复制代码 |
|