IwDbGrid中Column之动态建立

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-3528650120430763&dt=1183890684015&lmt=1183890684&format=468x60_as&output=html&correlator=1183890684000&url=http%3A%2F%2Fgmai9999.googlepages.com%2Fhome&ad_type=text_image&ui=rc%3A0&cc=100&flash=9&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="468" scrolling="no" height="60" allowtransparency="allowtransparency"> 

procedure TIWForm1.IWButton1Click(Sender: TObject);
var
  clm : TIWDbGridColumn;
begin

  clm := TIWDbGridColumn(IWDBGrid1.Columns.Add);
  clm.Title.Text := '编号';
  clm.DataField := 'ID';

  with ds do
  begin
    Active := false;
    CommandText := 'select ID from UseData ';
    open;
  end;
end; 

环境:

  BDS2006+Winxp Sp2+Acess2003

测试通过
name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-3528650120430763&dt=1183890684015&lmt=1183890684&format=468x60_as&output=html&correlator=1183890684000&url=http%3A%2F%2Fgmai9999.googlepages.com%2Fhome&ad_type=text_image&ui=rc%3A0&cc=100&flash=9&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="468" scrolling="no" height="60" allowtransparency="allowtransparency"> 

在使用Element UI的`el-table-column`组件时,如果你想根据数据动态添加图标(icon),可以通过`formatter`属性来实现。`formatter`属性允许你定义一个函数,该函数会在数据渲染到列之前被调用,你可以在这个函数返回任何你想要渲染的HTML内容。 下面是一个简单的例子,展示如何在`el-table-column`添加动态图标: ```html <template> <el-table :data="tableData" style="width: 100%"> <el-table-column prop="date" label="日期" width="180"> </el-table-column> <el-table-column prop="name" label="姓名" width="180"> </el-table-column> <el-table-column label="操作" width="180"> <template slot-scope="scope"> <!-- 使用formatter来动态生成内容 --> <i class="iconfont" :class="scope.row.statusIcon"></i> </template> </el-table-column> </el-table> </template> <script> export default { data() { return { tableData: [{ date: '2016-05-02', name: '王小虎', // 状态图标类名,例如:"icon-success","icon-fail" statusIcon: 'icon-success' }, { date: '2016-05-04', name: '张小刚', statusIcon: 'icon-fail' }] }; } }; </script> <style> /* 样式示例,根据实际情况引入对应的字体图标库 */ .iconfont { font-size: 18px; } /* 根据状态定义不同图标样式 */ .icon-success { color: green; } .icon-fail { color: red; } </style> ``` 在上面的代码,`icon-success`和`icon-fail`是示例性的类名,你需要根据实际使用的图标库来定义相应的类名。`formatter`属性没有直接使用,而是通过`<template slot-scope="scope">`的形式来自定义列内容,并通过`scope.row.statusIcon`动态绑定图标类名。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值