紧急求教:如何生成动态datawindow

gofaster 2003-10-13 06:03:54
请问各位高人,生成统计表时,要求随用户给定的条件的增加,动态的增加数据列,要求通过程序在datawindow中生成。例如统计多个单位各个部门的员工人数,一个单位为一列,程序的使用者可以随机的选择单位和部门。
...全文
123 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
gofaster 2003-10-21
  • 打赏
  • 举报
回复
感谢快乐白兔、workhand等朋友、动态增加列,实际上,就是动态构造sql语句,然后用dw_1.Create(SyntaxFromSQL(sqlca,SqlString, ...语句生成即可。
shiller 2003-10-18
  • 打赏
  • 举报
回复
如何显示的页眉为中文,等待中ing
yjhyn 2003-10-17
  • 打赏
  • 举报
回复
对,用create建立,然后用describe来删除释放内存
flyhot 2003-10-16
  • 打赏
  • 举报
回复
up
wantsong 2003-10-16
  • 打赏
  • 举报
回复
如果没有标,就临时生成一个,关闭窗口后删除
若是不同用户同时使用就生成不同的临时表
qqjj7758 2003-10-16
  • 打赏
  • 举报
回复
不好意思 this.object.code[row] 中 row 是个variable 是行数
code是数据列
这句话的意思是 dwo.object.column[rownumber]
bomber2001 2003-10-16
  • 打赏
  • 举报
回复
create......
你查看一下describe帮助,我想哪里可以给你答案
hkzhou 2003-10-16
  • 打赏
  • 举报
回复
qqjj7758能不能详细解释一下 谢谢
_________________________________________
this.object.code[row]指向的是哪一个东西
hkzhou 2003-10-16
  • 打赏
  • 举报
回复
好厉害 学习!
qqjj7758 2003-10-16
  • 打赏
  • 举报
回复
string dwsyntax
dwsyntax='release 9;~n'+&
'datawindow(units=0 timer_interval=0 color=1073741824 processing=1 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes hidegrayline=no grid.lines=0 )~n'+&
'header(height=80 color="536870912" )~n'+&
'summary(height=0 color="536870912" )~n'+&
'footer(height=0 color="536870912" )~n'+&
'detail(height=84 color="536870912" )~n'+&
'table(column=(type=char(1) update=yes updatewhereclause=yes key=yes name=code dbname="tb_product_code.code" )~n'+&
' column=(type=char(20) update=yes updatewhereclause=yes name=s'+this.object.code[row]+'_type dbname="tb_product_code.s'+this.object.code[row]+'_type" )~n'+&
' column=(type=char(20) update=yes updatewhereclause=yes name=s'+this.object.code[row]+'_measure dbname="tb_product_code.s'+this.object.code[row]+'_measure" )~n'+&
' retrieve="PBSELECT( VERSION(400) TABLE(NAME=~~"dbo.tb_product_code~~" ) COLUMN(NAME=~~"dbo.tb_product_code.code~~") COLUMN(NAME=~~"dbo.tb_product_code.s'+this.object.code[row]+'_type~~") COLUMN(NAME=~~"dbo.tb_product_code.s'+this.object.code[row]+'_measure~~")) " update="dbo.tb_product_code" updatewhere=1 updatekeyinplace=no )'+&
'text(band=header alignment="0" text="Code" border="0" color="33554432" x="9" y="8" height="64" width="146" html.valueishtml="0" name=code_t visible="1" font.face="穝灿砰" font.height="-10" font.weight="400" font.family="1" font.pitch="2" font.charset="136" background.mode="1" background.color="536870912" )~n'+&
'text(band=header alignment="0" text="S'+this.object.code[row]+'_Type" border="0" color="33554432" x="165" y="8" height="64" width="471" html.valueishtml="0" name=s'+this.object.code[row]+'_type_t visible="1" font.face="穝灿砰" font.height="-10" font.weight="400" font.family="1" font.pitch="2" font.charset="136" background.mode="1" background.color="536870912" )~n'+&
'text(band=header alignment="0" text="S'+this.object.code[row]+'_Measure" border="0" color="33554432" x="645" y="8" height="64" width="485" html.valueishtml="0" name=s'+this.object.code[row]+'_measure_t visible="1" font.face="穝灿砰" font.height="-10" font.weight="400" font.family="1" font.pitch="2" font.charset="136" background.mode="1" background.color="536870912" )~n'+&
'column(band=detail id=1 alignment="2" tabsequence=10 border="0" color="33554432" x="9" y="8" height="64" width="146" format="[general]" html.valueishtml="0" name=code visible="1" edit.limit=1 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0 edit.displayonly=yes font.face="Courier New" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )~n'+&
'column(band=detail id=2 alignment="0" tabsequence=20 border="0" color="33554432" x="165" y="8" height="64" width="471" format="[general]" html.valueishtml="0" name=s'+this.object.code[row]+'_type visible="1" edit.limit=20 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0 font.face="穝灿砰" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="136" background.mode="1" background.color="536870912" )~n'+&
'column(band=detail id=3 alignment="0" tabsequence=30 border="0" color="33554432" x="645" y="8" height="64" width="485" format="[general]" html.valueishtml="0" name=s'+this.object.code[row]+'_measure visible="1" edit.limit=20 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0 font.face="穝灿砰" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="136" background.mode="1" background.color="536870912" )~n'+&
'htmltable(border="1" )~n'+&
'htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" )~n'+&
'export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )~n'+&
'import.xml()~n'+&
'export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" )'

string sourcingtype,rem

if dw_sourcing_typemeasure.ModifiedCount()>0 then
if messagebox("矗ボ","暗筁э叫玂匡拒ˉ琌ˇ玂匡拒ˉˇ",QUESTION!,YESNO!,1)=1 then

else

sourcingtype = this.object.sourcing[row]
SELECT dbo.tb_product_code.sourcing
INTO :rem
FROM dbo.tb_product_code where sourcing=:sourcingtype ;

if sourcingtype<>"" and sqlca.sqlcode=0 then
dw_sourcing_typemeasure.Create(dwsyntax)

dw_sourcing_typemeasure.settransobject(sqlca)
dw_sourcing_typemeasure.retrieve()

dw_sourcing_typemeasure.setredraw(false)
dw_sourcing_typemeasure.BringToTop = TRUE
dw_sourcing_typemeasure.setredraw(True)


else
dw_sourcing_typemeasure.reset()
end if
end if
else
sourcingtype = this.object.name[row]
SELECT dbo.tb_product_code.sourcing
INTO :rem
FROM dbo.tb_product_code where sourcing=:sourcingtype ;

if sourcingtype<>"" and sqlca.sqlcode=0 then

dw_sourcing_typemeasure.Create(dwsyntax)

dw_sourcing_typemeasure.settransobject(sqlca)
dw_sourcing_typemeasure.retrieve()

dw_sourcing_typemeasure.setredraw(false)
dw_sourcing_typemeasure.BringToTop = TRUE
dw_sourcing_typemeasure.setredraw(True)


else
dw_sourcing_typemeasure.reset()
end if
end if
gofaster 2003-10-15
  • 打赏
  • 举报
回复
使用dw_new.create(ls_syntax,ls_error),需要服务器上存在相应的数据表,如果没有表,只是让dw显示查询结果,怎么办?
yjhyn 2003-10-15
  • 打赏
  • 举报
回复
动态数据窗创建原理及实现

在实际应用中,经常需要根据用户需求来动态创建数据窗,一般方法是这样的。

在一个window中加入一个数据窗控件,如dw_new,但是该数据窗没有data object,(空白的)
就可以用以下语法来创建:
dw_new.create(ls_syntax,ls_error) // 创建语法,错误信息
ls_syntax可以用以下三种方法来形成:

一、动态由sql语法创建:

// 连接到pb的example数据库
string ls_sql,ls_syntax,ls_error
ls_syntax = 'select * from department'
ls_syntax = sqlca.SyntaxFromSQL(ls_sql,'style(type=grid)',ls_error)
if len(ls_error) >0 then
messagebox('Error','SyntaxFromSQL Error:~r'+ls_error)
else
dw_new.create(ls_syntax,ls_error)
if len(ls_error) >0 then
MessageBox("Error", "Create have these errors: ~r" + ls_error)
else
dw_new.settransobject(sqlca)
dw_new.retrieve()
end if
end if

二、由另一个数据窗的syntax来创建

string ls_syntax,ls_error
ls_syntax = dw_test.describe('datawindow.syntax')
dw_new.create(ls_syntax,ls_error)
if ls_error <> '' then
messagebox('Create Error',ls_error)
else
dw_new.settransobject(sqlca)
dw_new.retrieve()
end if

三、读取psr文件来创建

样例
string ls_syntax,ls_error,ls_ret
ls_ret = char(13)+char(10) //回车键
int li_fileNum
long li_length
li_FileNum = FileOpen("efef.psr",Streammode!, read!, shared!, Replace!)

// 以下是pb5的代码
if li_filenum >0 then
FileSeek(li_FileNum, 158, FromBeginning!)
li_length = fileRead(li_filenum,ls_syntax)
end if
fileclose(li_filenum)
if li_length = 0 then return
ls_syntax = "release 5;"+ls_ret+ls_syntax

//截掉ls_syntax中的数据部分,5.0以"sparse(names="dept_name?) "作为参考位置
//6.0以html(作为参考位置

long pos1,pos2
pos1 = pos(ls_syntax,'sparse(names="',1)
pos2 = pos(ls_syntax,'"',pos1 +16)
ls_syntax = left(ls_syntax,pos1) + mid(ls_syntax,pos1 +1,pos2 - pos1 +1)

dw_New.create(ls_syntax,ls_error)

if ls_error <> '' then
messagebox('Create Error',ls_error)
else
dw_new.settransobject(sqlca)
dw_new.retrieve()
end if

转帖csdn,原来收集的,可以参考一下


xc008 2003-10-14
  • 打赏
  • 举报
回复
string ls_sql
ls_sql = dw_1.object.datawindow.syntax
dw_1.create(ls_sql)
dw_1.settransobject(sqlca)
dw_1.retrieve()
qiyousyc 2003-10-14
  • 打赏
  • 举报
回复
做数据窗口(包含全部列),将不显示的列宽度设置为0,

在增加列时,将相应的宽度设置为原来的宽度就可以了。
workhand 2003-10-14
  • 打赏
  • 举报
回复
补充column也要拼sql语句吧,然后create
china_0_1 2003-10-14
  • 打赏
  • 举报
回复
但是
dw_1.Create(SyntaxFromSQL(sqlca,SqlString, ...语句
其中SQlString是你的SQL语句,你要动态生成该字符串即可
在oracle数据上有时提示pb60.exe错误。这是什么原因?
zqbchina 2003-10-14
  • 打赏
  • 举报
回复
交叉风格的列表应该可以实现。
pb8oracle 2003-10-13
  • 打赏
  • 举报
回复
(我们不想建表,但是视图不知可不可以,而且不想只增加text控件,而是想加column)
在编辑数据窗口时,菜单有一个insert-〉column,但是在datawindow的column Specification 里有一个table存放可以增加的列,而如何用语句增加这个table的列并设置其属性!之后才插入column!谢谢!
有一定技术难题!是多名高手讨论过的!
rogery 2003-10-13
  • 打赏
  • 举报
回复
可以用以下方法来实现。

做一个表,存放这些随意性添加的字段。用此表做一个数据窗口,用check box选择要增加的列。然后选择不的字段,产生一个不同的返回值,来给数据窗口赋新的生成条件。
pb8oracle 2003-10-13
  • 打赏
  • 举报
回复
各位大侠:他要问的是没有表的动态增加Detail区的列!??
即增加column来补充数据窗口!
谢谢!
我也等着急用!
加载更多回复(2)

611

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder DataWindow
社区管理员
  • DataWindow社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧