데이터grid 방법 확장 - 편집기 추가 및 제거

1944 단어
$.extend($.fn.datagrid.methods,{
    addEditor:function(jq,param){//param , 
        if(param instanceof Array){
            $.each(param,function(index,item){
                //getColumnOption , field
                var e = $(jq).datagrid('getColumnOption',item.field);
                e.editor = item.editor;
            });
        }else{
            var e =  $(jq).datagrid('getColumnOption',param.field);// 。
            e.editor = item.editor;
        }
    },
    removeEditor:function(jq,param){
        if(param instanceof Array){
            $.each(param,function(index,item){// , editor 
                var e = $(jq).datagrid('getColumnOption',item);// 。
                e.editor = {};
            });
        }else{// , editor 
            var e =  $(jq).datagrid('getColumnOption',param);// 。
            e.editor = {};
        }
    }
});

사용 예:
$("#id").datagrid('removeEditor','password');// 'password' editor
$("#id").datagrid('removeEditor',['password','name']);// password name 

$("#id").datagrid('addEditor',// , field editor
                  {
                    field:'password',
                    editor:{type:'validatebox',
                            options:{required:true}
                            }
                   }
                );
$("#id").datagrid('addEditor',// , field editor
                  [
                      {
                        field:'password',
                        editor:{type:'validatebox',options:{required:true}}
                       },
                       {
                        field:'name',
                        editor:{type:'validatebox',options:{required:true}}
                       }
                   ]
                );

좋은 웹페이지 즐겨찾기