|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
: R# f& E% F# P1 W, Q4 g- {
+ S4 Z& ~7 {) d8 H3 ]$ C9 v) X) ^
. f# V* e( H9 F2 ], g
( E4 Z% L; I2 j h3 ~% o- u+ F
Technique 4 {5 A, N; }2 ^ p) @/ l" [( G4 A
There is no difference in setting up a query for a single Item or for many. Only the
1 D- y0 R V1 Q7 E t9 I# g6 Q1 vcriteria define the set size returned. In this recipe you create an Item and populate % j( W e+ ^: L1 G( ^8 ~% ]# D; u
the query criteria, apply it, and iterating over the Items returned producing a HTML , C& x3 |3 e4 V$ j% l) ]
<TABLE> fragment. 6 W' e% t7 ~1 o- O. V, O S
! ]- O2 B# a$ [3 Z
. T9 D6 A5 P. y% g7 A C
JavaScript % z* o3 b( ^5 a H5 S
var qryItem = this.newItem("Part","get");
8 j2 g0 j% {* G) ?9 u. V( }qryItem.setAttribute("select","item_number,description,cost"); $ u5 d1 c3 N! p* t, D; |. i8 v
qryItem.setProperty("cost", "100", "gt"); ! p9 J" u: n3 M
var results = qryItem.apply(); 4 w) p. {" `9 v- z
var count = results.getItemCount();
* X0 {) ~5 [) j" F. N' C; ^var content = "<table>"; - b E0 R- A! R) G
for (var i=0; i<count; ++i) ( o: |& X) C2 W4 K
{ 6 O/ x! _2 x7 E( y+ z
var item = results.getItemByIndex(i); 4 I# G2 E7 i- |, K4 f3 {
content += "" + 5 a$ z& Z" W$ k( Z
"<tr>" +
^! y# Z, E5 \ "<td>" + item.getProperty("item_number") + "</td>" +
# `1 p% Y4 E$ F! y "<td>" + item.getProperty("description") + "</td>" +
" X; |; n4 n+ ~ "<td>" + item.getProperty("cost") + "</td>" +
7 D. w5 A, T' _ ^( C$ Y0 ~" v; P "</tr>"; ' M- T. \0 I2 |7 D/ u% d
}
% V% G" B' a2 Q0 h% _0 Zcontent += "</table>";
+ B1 m& B' A: n6 C/ b& U: l* v# qreturn content;
3 `; n& a9 Z" R# ~) W6 D& r# Z 2 q9 K4 R, ^) f8 O/ t8 z) ]
C# 3 I+ z( I7 m+ o- w7 J- D
Item qryItem = this.newItem("Part","get");
1 Z I0 R) N4 r2 zqryItem.setAttribute("select","item_number,description,cost"); & q4 {) s4 w, f* u. S# j* C
qryItem.setProperty("cost", "100", "gt"); 4 A4 g6 U3 q/ ?8 i
Item results = qryItem.apply(); 3 b" V, I' _( D: G
int count = results.getItemCount(); 2 g6 W9 N3 `3 a, o9 Z
int i; . ?0 g( _7 n& Q8 y$ a& m
string content = "<table>"; 6 L* {5 o1 W( v) z
for (i=0; i<count; ++i)
V+ \ ?. B* @{
* ^ R, ~4 H# O% x/ y! X Item item = results.getItemByIndex(i); `* g; l% }' |! ^
content += "" +
& a& J) Y3 V9 A% z, i7 w! S "<tr>" + : N2 K7 I. e/ p9 \
"<td>" + item.getProperty("item_number") + "</td>" + 8 X7 H% b K; T) K" v0 p
"<td>" + item.getProperty("description") + "</td>" + ' A2 J ?# A. l& @3 Z* a( v
"<td>" + item.getProperty("cost") + "</td>" +
; @/ n8 k; r# g8 J2 N "</tr>";
1 g8 m3 e# ]- v% Q1 n! G+ r} ! h* K `8 J4 T1 C7 c# ?
content += "</table>"; 4 M% ~6 `$ n0 U$ w q Z r
Innovator innovator = this.newInnovator(); 6 A* b, f( c8 Y2 x1 k
return innovator.newResult(content);
/ G( Z7 W) M, J9 @9 y# b
7 C( c: |$ _; R9 I% Y& L& uVB.Net ) C8 m- z. K# ?7 h0 T# M& l2 [
Dim qryItem As Item = Me.NewItem("Part","get") ' O' v% e' h, ?( P( c& D6 a
qryItem.SetAttribute("select","item_number,description,cost") 8 R' L% N/ z6 d' V
qryItem.SetProperty("cost", "100", "gt") X; r5 m( P" q; |+ w
Dim results As Item = qryItem.Apply() 9 D' e! y( J% G
Dim count As Integer = results.GetItemCount() + D8 g! _* n5 U& ?
Dim i As Integer
% \. v5 Q0 {% o- b+ m2 |Dim content As String = "<table>" 0 Z! k4 ~+ p+ U3 ~! W
For i=0 to count - 1 8 s) i. b/ I) z" L& ]6 b0 a8 n
Dim item As Item = results.GetItemByIndex(i) ! T' j" q8 g7 Y; J
content += "" + _
4 A i% `! s8 g; g8 {4 E "<tr>" + _ $ y8 K C5 i$ u6 g) j
"<td>" + item.GetProperty("item_number") + "</td>" + _
. t4 G! A. l9 B+ J; i7 B "<td>" + item.GetProperty("description") + "</td>" + _
\7 h6 X' \. B0 n6 H/ ]1 R% |/ K "<td>" + item.GetProperty("cost") + "</td>" + _ # ~ {+ i) r6 O
"</tr>" 5 q! v. z6 ?: h
Next % V7 C5 Y W/ O: W9 e5 Q
content += "</table>"
0 q5 C! }' t2 B1 q
3 g% a" F4 b/ _0 U, C3 cDim innovator As Innovator = Me.NewInnovator() , y: l" S" r/ B0 g! ?' ?
return innovator.NewResult(content) 5 D% d7 z5 B/ e1 t- W7 t
( u. h P9 {. @+ ~5 D5 F. y# m
8 h+ l6 m* R# g {$ T) L |
|