|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* G. W- e' v% n$ T! ~$ D) ^* d
6 q5 d* B. w2 m
, y" e, y g, c1 k7 g* G/ F Y2 W) z7 v* }- M9 l
Technique
4 g* p ?( ^1 q( Z' PThere is no difference in setting up a query for a single Item or for many. Only the
# X& S1 f. ?$ ^- fcriteria define the set size returned. In this recipe you create an Item and populate 9 z, h9 S$ m) T. h, q
the query criteria, apply it, and iterating over the Items returned producing a HTML : j% `8 G' l% d2 U
<TABLE> fragment. 3 ?- S+ ?( Z* P/ l9 a
1 l9 U1 B; S$ Y4 F' i0 J4 |
( {. p. m& Y, z! d9 K, h4 n% y8 a
JavaScript
U, `7 _) e* x0 @7 ?1 dvar qryItem = this.newItem("Part","get");
* d: ^$ l& W/ B3 V6 v) a& LqryItem.setAttribute("select","item_number,description,cost");
7 V" G$ c m! t# b cqryItem.setProperty("cost", "100", "gt");
8 `8 Z# e, t0 y7 Y3 Avar results = qryItem.apply();
' v: R, G) s! P* v" mvar count = results.getItemCount(); $ s& [- m' }4 @( ^% e
var content = "<table>"; , B' h, t$ O" u ], i0 u
for (var i=0; i<count; ++i) ; L% t& g8 O5 u0 c, ^) c
{ 0 a* k- @! t6 C# ] E2 C0 g
var item = results.getItemByIndex(i);
& J9 A& c' Y7 c6 I- _$ J content += "" + - H5 w- _9 _ G: ~
"<tr>" + , C0 q2 z) m& q5 x" P6 \$ w
"<td>" + item.getProperty("item_number") + "</td>" + ; W" w6 f" m/ o" t
"<td>" + item.getProperty("description") + "</td>" + : z) n. q! ?& Q/ i: c2 ~
"<td>" + item.getProperty("cost") + "</td>" +
, }3 b* Z/ T7 ~% s6 U "</tr>"; / L* g7 |% X( }1 Y+ P9 v
} 4 o x4 ]. y0 a! _
content += "</table>"; / F( R+ C6 J3 i
return content; ) w2 t# j" y7 {' }7 Z2 {
8 n. g3 p u; M; s* R1 u
C# & |9 O- ?+ {/ o2 m
Item qryItem = this.newItem("Part","get"); 6 x3 I% _7 {, J$ l: k
qryItem.setAttribute("select","item_number,description,cost"); . | n. P3 g" L. \. F# n7 F, d* J* _
qryItem.setProperty("cost", "100", "gt"); Q. _+ f7 t5 N6 n# s
Item results = qryItem.apply(); 0 @1 [' d# N% w1 X
int count = results.getItemCount();
0 m" k i8 ^- C! Y$ o, t, z% Y; kint i; 8 j: U4 j: m. ~# [* V5 U
string content = "<table>";
0 I% I6 q2 @+ Hfor (i=0; i<count; ++i)
6 X# s. z; @& A{
0 N/ i& R/ q! O" T, p Item item = results.getItemByIndex(i);
3 @" d! S4 ~6 M, n; N. u+ | content += "" +
7 C8 m) s5 O& a% W4 ^# @ "<tr>" +
6 Z3 L7 v* k+ u6 K3 Q "<td>" + item.getProperty("item_number") + "</td>" + ) r9 v! h% C! |2 ~* X; ?8 D
"<td>" + item.getProperty("description") + "</td>" + - l( e! K5 y* N7 E) f4 V2 j& P
"<td>" + item.getProperty("cost") + "</td>" + $ k2 `6 L7 R' Z" N
"</tr>";
+ X$ {( P8 }4 N5 }' ^4 C( T} ; ?! U+ ]7 q- e
content += "</table>"; * l1 h% h1 d$ ]: d* X. h( P$ Y
Innovator innovator = this.newInnovator();
, Q$ `, h; ~* G% T- Ereturn innovator.newResult(content);
7 L" [1 |/ z" D
4 B+ P$ \# ~9 m `6 J9 u' G& I9 lVB.Net
5 x2 k8 ~2 t9 _# pDim qryItem As Item = Me.NewItem("Part","get")
! u/ V0 i% p( K$ ^4 r! v! f7 i' }9 o8 FqryItem.SetAttribute("select","item_number,description,cost") 6 m$ O q8 y9 @- \1 d8 S
qryItem.SetProperty("cost", "100", "gt")
3 p- b* N& ] \* P' y5 uDim results As Item = qryItem.Apply()
( g! w5 I5 t& o+ ^! v1 zDim count As Integer = results.GetItemCount() 6 }: X. }, |" H1 \; a. ~
Dim i As Integer
F* K& i q0 m- `Dim content As String = "<table>" 5 `2 K2 e5 k2 Z# j/ g
For i=0 to count - 1 / K8 z+ V: s4 R
Dim item As Item = results.GetItemByIndex(i) 1 l* O1 U7 h* q' |
content += "" + _ 9 |; I% X6 o6 o' `# V
"<tr>" + _ $ y. F; _3 W5 Y- ]5 l3 B
"<td>" + item.GetProperty("item_number") + "</td>" + _
( G" j( e/ ~8 }( X; L "<td>" + item.GetProperty("description") + "</td>" + _ 2 f3 `6 U, S8 n ?: h. n# a C
"<td>" + item.GetProperty("cost") + "</td>" + _
( \, N- i J( t( H "</tr>"
0 o# b$ O& R: T9 b: v1 SNext ! w) U+ J2 g5 T& L) a, i; ^! t
content += "</table>"
; g! u" f+ s. ?- v( T( u: y: e 6 t' p# K; }% f( k, v
Dim innovator As Innovator = Me.NewInnovator() / I- C" _. t* }/ Y' c9 @# s3 J
return innovator.NewResult(content)
+ p2 R, i+ F2 S$ x; C5 Z P5 a$ C d# H# W9 ~
1 Z; P% ^' y/ j. m" K' \ |
|