为bootstrap+angularJs打造的表格代码生成器

 

private void btnCreateCode_Click(object sender, EventArgs e)
{
string objName = txtObjName.Text;
if (objName.Length <= 0) {
MessageBox.Show("缺少对象名");
return;
}
string[] objPros = rtbObjPro.Lines;
if (objPros.Length <= 0) {
MessageBox.Show("缺少属性项");
return;
}
StringBuilder sbResult = new StringBuilder(); 

sbResult.AppendLine(@"<div class=""table - responsive"">");
sbResult.AppendLine(@" <table class=""table table - striped"">");
sbResult.AppendLine(@" <thead>");
sbResult.AppendLine(@" <tr>");
//creat th info
string strtmp = "";
for (int i = 0; i < objPros.Length; i++) {
strtmp = "<th>" + objPros[i].ToString() + @"</th>";
sbResult.AppendLine(" "+strtmp);
}
sbResult.AppendLine(@" </tr>");
sbResult.AppendLine(@" </thead>");
sbResult.AppendLine(@" <tbody>");
strtmp = @" <tr ng-repeat=""" + objName + " in " + objName + "s " + "track by " + objName + ".id>";
sbResult.AppendLine(strtmp); 

sbResult.AppendLine(" <td>{{" + objName +".id}}</td>");
for (int i = 0; i < objPros.Length; i++){
strtmp = "<td>{{" + objName + "." + objPros[i].ToString() + @"}}</td>";
sbResult.AppendLine(" " + strtmp);
}
sbResult.AppendLine(@" <td class=""text - right"">");
sbResult.AppendLine(@" <button type=""button"" ");
sbResult.AppendLine(@" class=""btn btn - info btn - sm""> ");
sbResult.AppendLine(@" <span class=""glyphicon glyphicon - eye - open""></span>");
sbResult.AppendLine(@" </button>");
sbResult.AppendLine(@" <button type=""button"" ");
sbResult.AppendLine(@" class=""btn btn-primary btn-sm""> ");
sbResult.AppendLine(@" <span class=""glyphicon glyphicon-pencil""></span>");
sbResult.AppendLine(@" </button>");
sbResult.AppendLine(@" <button type=""button"" ");
sbResult.AppendLine(@" class=""btn btn-danger btn-sm""> ");
sbResult.AppendLine(@" <span class=""glyphicon glyphicon-remove-circle""></span>");
sbResult.AppendLine(@" </button>");
sbResult.AppendLine(@" </td>");
sbResult.AppendLine(@" </tr>");
sbResult.AppendLine(@" </tbody>");
sbResult.AppendLine(@" </table>");
sbResult.AppendLine(@"</div>");
sbResult.AppendLine(@"<div class=""text - center"">");
sbResult.AppendLine(@" <uib-pagination class=""pagination - sm"" total-items=""totalItems"" ng-model=""page"" ng-change=""loadAll()""></uib-pagination>");
sbResult.AppendLine(@"</div>");
rtbResult.Text = sbResult.ToString();
}
}

转载于:https://www.cnblogs.com/chqq2018/p/9965107.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值