为uniDBGrid的序号列加标题
UniSession.AddJS ('MainForm.UniDBGrid1.columnManager.columns[0].setText("选择")'); UniSession.AddJS ('MainForm.UniDBGrid1.columnManager.columns[1].setText("序号")');
朋友给我的代码,设置uniDBGrid的序号标题。参考上面的代码,为了适应uniForm,uniFrame等继承,改成下面这样:
对于uniForm,我们在AfterShow事件中处理:
procedure TAddMDTableBase.UniFormAfterShow(Sender: TObject); begin inherited; //为Grid的序号列设置标题 if (dgRowNumbers in UniDBGrid1.Options) then begin //UniSession.AddJS('MainForm.UniDBGrid1.columnManager.columns[0].setText("选择")'); UniSession.AddJS(Self.Name+'.UniDBGrid1.columnManager.columns[0].setText("序号")'); end; end;
对于uniFrame,我们要在UniDBGrid1AfterLoad中处理:
procedure TOneTableBase.UniDBGrid1AfterLoad(Sender: TUniCustomDBGrid); begin inherited; //为Grid的序号列设置标题 if (dgRowNumbers in UniDBGrid1.Options) then begin //UniSession.AddJS('MainForm.UniDBGrid1.columnManager.columns[0].setText("选择")'); UniSession.AddJS(Self.Name+'.UniDBGrid1.columnManager.columns[0].setText("序号")'); end; end;
最后的显示结果:
另外,参考上面的代码,我们还可以设置列的宽度等:
('MainForm.UniDBGrid1.columnManager.columns[0].setWidth(55)');
感谢007的支持!