$(this).data(“_ItemTemplate”,$(this).find(“.itemtemplate”).toHTML());
$(this).find(“.itemtemplate”).remove();
}
var TrContentTemplate=$(this).data(“_ItemTemplate”);
//
var fileds=____FindFiled(TrContentTemplate);//找到所有列
if(fileds==null )return false ;
var filedscount=fileds.length;//计算列数
////
$(this).data(“_DataSrc”,val); //将数据放入缓存
var count=val.length;
for(var i=0;i<count ;i++){
////绑定列值
var NewTrContent=TrContentTemplate;
//
NewTrContent=NewTrContent.Replace(“{{“,”{#”);
NewTrContent=NewTrContent.Replace(“}}”,”#}”);
for( var j=0;j<filedscount;j++){
NewTrContent=NewTrContent.Replace(“{“+fileds[j]+”}”,val[i][fileds[j].trim()]);
}
NewTrContent=NewTrContent.Replace(“{#”,”{“);
NewTrContent=NewTrContent.Replace(“#}”,”}”);
//
var area=$(this).find(‘tbody’);
if(area ==null )
area =$(this);
//
area.append(NewTrContent);
if(ItemCreatedCallBack!=null ){
ItemCreatedCallBack($(this).find(domtype+”:last”));
}
}
//
$(this).RepeaterSetItemClass($(this).data(“_class1”),$(this).data(“_class2”),$(this).data(“_hoverClass”));
}
});
},
RepeaterClear:function (){//清除数据
this.each(function(){
if($(this).data(“_ItemTemplate”)==null ){
$(this).data(“_ItemTemplate”,$(this).find(“.itemtemplate”).toHTML());
}
$(this).find(“.itemtemplate”).remove();
});
},
RepeaterSetItemClass:function (class1,class2,hoverClass){//行样式
this.each(function(){
if(class1==null || class2==null || hoverClass ==null )
return ;
//将设置存入缓存
$(this).data(“_class1”,class1);
$(this).data(“_class2”,class2);
$(this).data(“_hoverClass”,hoverClass);
//
if($(this).data(“_DataSrc”)!=null ){
var domtype=$(this).find(“.itemtemplate”).attr(‘nodeName’);
//
$(this).find(domtype).addClass(class1);
$(this).find(domtype+”:nth-child(even)”).addClass(class2);
// $(this).find(domtype+”:first”).removeClass(class1);
//鼠标移动上去颜色变化
$(this).find(domtype).hover(function(){$(this).addClass(hoverClass);},function(){$(this).removeClass(hoverClass);});
}
});
}
});
//查找字段公共方法.
function ____FindFiled(str){//公共方法.
var myRegex = new RegExp(“{.+?}”, “gim”);
//var arr = myRegex.exec(str);
var arr=str.match(myRegex);
if(arr ==null )return null ;
var count=arr.length;
for( var i=0;i<count;i++)
{
arr[i]=arr[i].Replace(“{“,””).Replace(“}”,””);
}










