|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 s! g7 h: i/ E) D# H: \, i' k
4 F% d9 Z& }9 n4 M& L5 l/ k! m/ E! P/ O
" @8 A8 d( m# ~/ m3 T: ?8 o) y9 Q4 H: ~) Y" J
Technique
& o1 \5 Q4 b* G7 bThere is no difference in setting up a query for a single Item or for many. Only the
\3 t7 |; F0 R y) U6 Qcriteria define the set size returned. In this recipe you create an Item and populate # p& t2 n5 L" Z. r/ x
the query criteria, apply it, and iterating over the Items returned producing a HTML / H" m6 N% B/ B/ R* y
<TABLE> fragment.
- V1 b ?% u, L! R/ {
. l# A2 W, b$ I/ D' l1 q8 L/ a; r4 l1 j; R8 Z. |5 U
JavaScript / D7 Q2 p9 ?& z: N) F1 \
var qryItem = this.newItem("Part","get");
; x. G1 D6 E: \; F' A6 sqryItem.setAttribute("select","item_number,description,cost"); " W `; Z+ ]5 }; m2 B5 L
qryItem.setProperty("cost", "100", "gt"); , u+ s5 J2 @3 w; U7 C" H7 l
var results = qryItem.apply(); # }: q% u4 J. \6 R
var count = results.getItemCount();
- U3 ~9 d1 \" ^7 b6 r- rvar content = "<table>";
$ x: @# X1 n4 s% y4 @3 efor (var i=0; i<count; ++i) , i$ t D- M6 P H
{ & E+ W8 ~0 v8 }$ R: M6 ~
var item = results.getItemByIndex(i);
: \# p5 p& e. R% n* } content += "" + 4 K8 O0 w" s6 h2 D0 u8 v% S- q8 p
"<tr>" + * E' z @% B- r
"<td>" + item.getProperty("item_number") + "</td>" + 4 Y" I, \7 L; ^2 v
"<td>" + item.getProperty("description") + "</td>" +
q7 ^9 C4 H! p% Y2 S "<td>" + item.getProperty("cost") + "</td>" +
2 O% q5 _ R! j' G* _' H5 G! L9 X "</tr>"; * b' Q8 ]. v1 b! v
} # p3 E w8 ~$ w3 L' R2 W4 g; `) |
content += "</table>";
+ f6 [1 U0 ?1 o' E0 ureturn content; " b2 u( N7 ]) w& _6 t" M/ r
! I, K3 t" ^/ j6 G1 _C# $ [1 G! K- j" E- h0 d
Item qryItem = this.newItem("Part","get"); 6 x. k, u3 f( c" R; g
qryItem.setAttribute("select","item_number,description,cost"); - v5 _( A# ~0 v5 [+ {
qryItem.setProperty("cost", "100", "gt"); 4 l" f$ }% I( S/ c* A; m
Item results = qryItem.apply();
) j0 }9 q" t+ K% q, q$ t7 M4 bint count = results.getItemCount(); 6 s3 n- N7 i( q9 l" v& O! s
int i;
; \" T9 O& X* O% ^string content = "<table>";
. j6 S4 n4 k7 ~9 afor (i=0; i<count; ++i)
& r( A* n: S. s1 T9 s{ " d6 v( {; K/ N6 k# P
Item item = results.getItemByIndex(i); " G. q- w) B9 {) G/ A% u
content += "" + / ~; C8 L9 ~. {! Y; X0 F/ T
"<tr>" +
0 K% ~) @9 p6 B/ D5 N, j I$ ?! x "<td>" + item.getProperty("item_number") + "</td>" + + @! Z; r$ Q2 C8 J8 \
"<td>" + item.getProperty("description") + "</td>" + 4 |5 l5 R# M; A9 T! G, @
"<td>" + item.getProperty("cost") + "</td>" +
$ _% x' R4 E. [8 M$ g# P6 l: L2 K "</tr>"; # n7 \, b% U6 X) q: k
}
* S5 o; e1 G, c3 w4 Wcontent += "</table>";
' J5 N9 X8 `6 H. V; O6 l4 EInnovator innovator = this.newInnovator(); " ^/ m* S1 j3 a
return innovator.newResult(content); 8 A0 E. ?" e* T7 l
# _, m) G9 F' I; I3 X, ?, g! ~7 }" QVB.Net
# Z. ~, @5 q/ Y! a. E, p* o1 }Dim qryItem As Item = Me.NewItem("Part","get")
9 g* p4 V, n% b% fqryItem.SetAttribute("select","item_number,description,cost") / L% s+ Z, P8 I5 V( v5 L" ^
qryItem.SetProperty("cost", "100", "gt")
$ s; m- q6 J# ~5 Y5 r; }0 e7 PDim results As Item = qryItem.Apply() / t( e! f+ T" K$ {9 p
Dim count As Integer = results.GetItemCount()
5 y: u, w3 \+ S% E9 }( PDim i As Integer , W$ M; m+ U+ G6 Z) K! V/ c
Dim content As String = "<table>" + y* `* O8 [, \+ G& c; |- c
For i=0 to count - 1
8 _' _3 H9 `; I" F* a Dim item As Item = results.GetItemByIndex(i)
! ?* | n' \! O$ w$ ~1 U0 f content += "" + _ 0 N# m; D1 k$ N: h6 P
"<tr>" + _ ( c( I' K0 |3 _6 [( M& e% ]0 o
"<td>" + item.GetProperty("item_number") + "</td>" + _ : h* |2 ^3 ]! [" P
"<td>" + item.GetProperty("description") + "</td>" + _
: N3 O" T3 p5 q4 {1 Z8 K/ e "<td>" + item.GetProperty("cost") + "</td>" + _
: o$ _! _1 p: z3 Z* H& @ "</tr>" $ T5 u4 d9 j# R
Next
5 g5 }' k0 T: A- Ccontent += "</table>" + G% m# X9 {3 {2 a3 A* p" J. J
' a1 D! g5 {6 Z7 k
Dim innovator As Innovator = Me.NewInnovator() $ C" W# P8 i9 ~3 L2 B
return innovator.NewResult(content)
8 t7 H9 j4 Y" S$ o& d, E& Z6 |& F; l' T2 X
* S7 \* f+ c* j$ J5 r4 R \ |
|