|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% j5 R/ {5 U* Z; u4 y1 b
: I. u: q' Z* w- a' G& O
9 B% ?8 w$ S7 P% B* \
! J Y9 A$ U& i' @5 z0 \, vTechnique
# U" A) I0 f; |1 Z2 }There is no difference in setting up a query for a single Item or for many. Only the 8 l6 V( R/ R. c& g! H A
criteria define the set size returned. In this recipe you create an Item and populate
1 D, H/ S: [: c! E, Ethe query criteria, apply it, and iterating over the Items returned producing a HTML $ ?. c) _5 ~! s, w: j o- q2 l
<TABLE> fragment.
; R$ R8 S- p3 h
/ X' E$ h! t0 K3 Q) b, B7 D. q
5 b7 R( E- [8 o4 _. |* rJavaScript
- o! w, A- U, A- u5 s7 \: Hvar qryItem = this.newItem("Part","get"); 8 a- m3 C* o! S% O4 Q
qryItem.setAttribute("select","item_number,description,cost");
" k: @# ?- h6 p4 Q1 O+ aqryItem.setProperty("cost", "100", "gt"); : E3 X$ T; C% k4 d+ l* d% n- C# t
var results = qryItem.apply();
# i7 D+ }( m; l2 O ]$ zvar count = results.getItemCount(); + m0 a8 B; [/ K( v
var content = "<table>"; / l4 X: E8 x4 j& m
for (var i=0; i<count; ++i) ' ^ N3 C8 G( n9 M) ^
{
+ l4 N* u4 c" v2 B- t var item = results.getItemByIndex(i);
0 T2 d2 s9 g+ {! P& o7 y content += "" +
% Y) `7 `. A& W+ w( u3 q "<tr>" + + S" J; G8 c, E2 V# [5 c- q
"<td>" + item.getProperty("item_number") + "</td>" + 4 C! i5 w: q* _% D0 G7 D; q; Y
"<td>" + item.getProperty("description") + "</td>" + 1 P. M% r: j/ K; {+ E+ l! S
"<td>" + item.getProperty("cost") + "</td>" +
, \% Y. g7 N) u: K$ g( _ "</tr>"; F& P8 u8 p, R* S4 y: L$ P
} - U( \% \8 P2 _: P; c7 C
content += "</table>";
+ z6 {9 Q' A @6 m5 \3 V/ Q7 {) vreturn content;
+ g# \6 {& W* M3 o4 c 1 ]1 s6 u: H3 b! B7 M: d
C# 8 R. f C( P1 f x
Item qryItem = this.newItem("Part","get");
2 o5 c6 T' ~! x% K3 Q) t; jqryItem.setAttribute("select","item_number,description,cost");
' y4 x/ x5 h7 B x- l9 HqryItem.setProperty("cost", "100", "gt"); " m' J8 d b! s
Item results = qryItem.apply(); 4 p. U1 O& g. X- Y" y; d
int count = results.getItemCount();
# G$ u q- r7 m0 z+ V# ~) p, [int i;
/ D+ ~0 |* C0 a, i+ w: u! rstring content = "<table>";
7 _6 E* y. q8 r# r4 q0 h+ G1 O4 G8 Z) cfor (i=0; i<count; ++i)
+ W8 O' a8 r: w& j1 u9 I{
+ k. W% S3 ?' C; N8 @" e% l/ a: s% w Item item = results.getItemByIndex(i); - ]4 w& b9 p: O: i, A
content += "" + & X; h1 |. t: e8 Q8 L; C/ \
"<tr>" +
* l" H6 P A+ ?' r# j* g+ D- L "<td>" + item.getProperty("item_number") + "</td>" + 7 V. a& \$ J& m) Z
"<td>" + item.getProperty("description") + "</td>" + 1 x5 ]0 V6 }1 N! `
"<td>" + item.getProperty("cost") + "</td>" + ! t3 b, p0 n& E5 _/ }+ s/ y
"</tr>";
3 T( Y: T' m7 o& a4 ~" h/ ^2 X+ U} 1 l" f4 f9 p4 x% n+ B
content += "</table>"; 5 ^; [1 U6 ]. V; @1 o0 I
Innovator innovator = this.newInnovator();
5 a2 j; y, u2 dreturn innovator.newResult(content); * _9 Q r$ [0 l1 k3 @1 K& m
! V- M- [5 ]1 {3 C8 N( d
VB.Net * `& [/ _$ L" I# N$ K
Dim qryItem As Item = Me.NewItem("Part","get")
|. W' R' P x3 J6 i8 }' uqryItem.SetAttribute("select","item_number,description,cost") ; [6 S6 b3 z; ~( f: C8 C- p
qryItem.SetProperty("cost", "100", "gt") + I4 l1 k6 u. r2 Q" P8 c) H& o2 K3 \
Dim results As Item = qryItem.Apply() 1 h% E; p8 L9 n: h; }! t- ]; R8 r
Dim count As Integer = results.GetItemCount()
0 c2 |9 A! F+ T6 `, n$ R0 w7 hDim i As Integer
`# s5 [$ _8 [% ^% M ~: QDim content As String = "<table>" # B* O5 ]" w2 E3 N/ Q2 p
For i=0 to count - 1 - S2 `, F4 d2 a' u) l
Dim item As Item = results.GetItemByIndex(i)
6 P/ H. K6 G6 `5 c% r0 {# ^. V content += "" + _ 4 v. N8 P# N' a
"<tr>" + _ ; M9 G8 [; F4 b4 u" f* |
"<td>" + item.GetProperty("item_number") + "</td>" + _ & A# d- {2 O5 f' q0 X
"<td>" + item.GetProperty("description") + "</td>" + _
2 |* B1 S6 E/ M0 |" { "<td>" + item.GetProperty("cost") + "</td>" + _ 1 ~. \8 S) f/ t1 M
"</tr>"
4 j# C3 n1 ?" P# L& M- S' ]8 fNext
- m7 H/ B( c1 _1 E7 ycontent += "</table>" ; f {) U" W' T0 ]
4 [4 ]) S2 R# g' y' z; }7 {% L
Dim innovator As Innovator = Me.NewInnovator()
" x! H1 Y" U3 I2 Y: Oreturn innovator.NewResult(content) + u( Z- V7 f9 x* u, k7 H# W
7 Q- J0 ]( T% ?) s8 D/ r( D! G) Z& u: L9 G$ C
|
|