|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
" A# ~* F8 w* a" q0 f+ J3 Y
8 \7 i; J8 j5 }5 X/ a, N: \- d/ F. V5 x* f- B( P0 v
. M- E7 a, c' i8 t8 h: A) FTechnique ' e+ h: ~1 O8 V* |) U, g
There is no difference in setting up a query for a single Item or for many. Only the 5 @6 [9 w" h. R0 o* m
criteria define the set size returned. In this recipe you create an Item and populate + h+ X8 _3 H, a5 t4 W: G/ s
the query criteria, apply it, and iterating over the Items returned producing a HTML 3 a( H4 A' h, S- o/ x
<TABLE> fragment.
# s1 x3 Y: p$ C3 Q
# S" `3 j8 O) B, T& B2 Z% U( a9 z! Y+ V; W N" U
JavaScript
+ K! j) v2 y6 y- B& Zvar qryItem = this.newItem("Part","get");
* {, J3 V2 N6 v/ ~0 SqryItem.setAttribute("select","item_number,description,cost"); ! ^& O6 y9 S9 U1 @1 `
qryItem.setProperty("cost", "100", "gt");
! g7 C4 Y: x. J# o) Q6 qvar results = qryItem.apply(); / f" b/ Q1 @. V& L* \3 i
var count = results.getItemCount(); ) J/ z$ q. w0 d! i+ K3 }* q
var content = "<table>";
' f3 F6 C# s* j; O) ~) l* G! d4 P9 } kfor (var i=0; i<count; ++i) ; f" a s8 T7 R, l- B6 ^
{ ) u; `& f/ S) X1 ]: O0 c
var item = results.getItemByIndex(i); + u% t: U, x4 ^$ I" |( h
content += "" +
+ c' X" R% E4 p. `/ V "<tr>" + ) N- N' B& c) Q
"<td>" + item.getProperty("item_number") + "</td>" + , e4 b& d! n2 Q+ j- m$ l
"<td>" + item.getProperty("description") + "</td>" + 8 ]& I# a/ Y9 p& U
"<td>" + item.getProperty("cost") + "</td>" + 9 P2 I @* p0 v% I( K
"</tr>";
. P6 c6 N0 r# @ @2 ]) S} + Q! y! h/ n& w/ k% A% C' G
content += "</table>"; , p# {. ^- a3 J
return content;
9 o! c* Y: h& O7 a* J8 c5 i2 ? ! l5 E+ w0 g* h a! M$ ]5 k
C# ' q) k% K5 i; M. x) i) J3 e
Item qryItem = this.newItem("Part","get"); 6 a X& e9 b& d7 K, v% _# r' _% y
qryItem.setAttribute("select","item_number,description,cost");
5 K% |' q8 A5 M3 d, T6 y" T0 V# TqryItem.setProperty("cost", "100", "gt"); 5 X. @7 I1 ?& X5 W' k% s( b+ n1 ^
Item results = qryItem.apply();
+ `3 q: E/ f+ B5 rint count = results.getItemCount();
+ H1 e7 s4 `7 d; S7 n' g: zint i;
# a! e( L, b7 ^" ^7 Dstring content = "<table>";
/ _9 c) l' n) D3 T. R- A5 O, K8 ?0 E% `for (i=0; i<count; ++i) w2 m9 s& Q' i7 T1 Z
{ & K$ D' D U8 M1 J1 [
Item item = results.getItemByIndex(i);
. P7 E" T6 d& g. o7 @. f) P" p9 p( \ content += "" + . E8 M: e' Q; i' @" q
"<tr>" + , v, l0 S% [! |/ {
"<td>" + item.getProperty("item_number") + "</td>" +
; ?: j/ }, f) H, _ "<td>" + item.getProperty("description") + "</td>" +
0 X4 u& V3 f% m {2 ~ "<td>" + item.getProperty("cost") + "</td>" + 6 ~* z9 |3 E) ~
"</tr>";
3 L/ D: R3 b! g' q7 P, u} 3 M9 s( y* b4 S& ?1 d$ s
content += "</table>";
# m% _4 ?0 d v% a3 OInnovator innovator = this.newInnovator(); , L0 \, c1 s3 b T2 a z# b
return innovator.newResult(content); 9 w2 b0 R, {2 ? W. r0 Y
0 v5 {6 n: }$ G3 F9 `" dVB.Net
0 [$ X Y5 ^! h) i- K: kDim qryItem As Item = Me.NewItem("Part","get")
; P5 ]; k3 X5 j' N' aqryItem.SetAttribute("select","item_number,description,cost")
$ O) C; R$ B, V) N IqryItem.SetProperty("cost", "100", "gt")
& V3 A I$ J2 V3 ?7 |2 [7 YDim results As Item = qryItem.Apply() 8 j2 _2 Y- w1 X/ X8 C! e' n
Dim count As Integer = results.GetItemCount()
- m- y; j. b# ? z9 oDim i As Integer
* v3 S+ p6 V) b# ]Dim content As String = "<table>" ! W! n& Y8 J7 P
For i=0 to count - 1
/ D- p7 y7 A$ n; ]' n Dim item As Item = results.GetItemByIndex(i) 5 h2 c& W. c: p
content += "" + _ 8 L9 J' |8 v) I1 p- C4 Y6 @
"<tr>" + _ 3 Y( A* j) d S) L
"<td>" + item.GetProperty("item_number") + "</td>" + _ 6 H0 s2 e( B0 g) c" o
"<td>" + item.GetProperty("description") + "</td>" + _ , g- m3 d4 a1 L5 z6 A
"<td>" + item.GetProperty("cost") + "</td>" + _ ) R+ Y; Z9 X) `/ \! c Y/ P
"</tr>" , w$ l+ |3 \! G) `
Next 4 a6 [) V2 t: V0 g( e ^- C
content += "</table>"
. c' B; O* g7 Y0 i. S
$ K4 u+ Z2 D$ S. N( n5 r2 {Dim innovator As Innovator = Me.NewInnovator()
$ r# |& M/ W; } }; a$ P2 R' b6 {% Dreturn innovator.NewResult(content)
3 p. ~# o# r. T3 u4 B M
% m5 i- ?# ~1 G8 G1 x3 g
8 D) Q, g" c; I |
|