|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
2 a3 \1 @. W9 t. F* v
" I- w h0 P" Z
1 ]* @3 a. Y+ M2 C% ~+ A
+ _ d( L2 h; l9 \9 h$ R6 V" O3 wTechnique
( z r9 [% c- o% G' \$ fThere is no difference in setting up a query for a single Item or for many. Only the
8 _* U0 ]. R2 `6 W f9 tcriteria define the set size returned. In this recipe you create an Item and populate 8 d, l- ^: ^# a
the query criteria, apply it, and iterating over the Items returned producing a HTML
4 n; I, y. q$ i; v" s" r<TABLE> fragment.
; q! S7 f& D5 y Q' H |" j1 i( r' n9 D6 H! H9 ]
5 U2 {3 L ~. l! ^) Q+ s0 R# t# EJavaScript ' N; u/ {' ?$ l) y4 y2 x
var qryItem = this.newItem("Part","get"); 2 P# }; K9 M/ X9 |
qryItem.setAttribute("select","item_number,description,cost");
4 P' O/ P8 ?; Y# [* sqryItem.setProperty("cost", "100", "gt");
" Z8 A1 c% j* [: R4 O7 r J+ uvar results = qryItem.apply(); / |/ P# }) c" d4 l2 n4 g
var count = results.getItemCount();
$ w; n7 h1 Z3 l" {var content = "<table>";
9 R5 V0 q, X) f3 d* Q3 |for (var i=0; i<count; ++i) 0 }* P' K( \! c" y* S
{ ) }; b6 g1 }! f$ l9 t
var item = results.getItemByIndex(i);
1 N/ E: \; u% B2 J content += "" +
+ p* ~9 \% f- ^& ^6 i "<tr>" + 0 s |$ E5 e% o" u4 M/ @+ ?- u
"<td>" + item.getProperty("item_number") + "</td>" +
0 }2 e2 v9 w6 g& V$ R- _ "<td>" + item.getProperty("description") + "</td>" + 6 M2 B5 U/ S8 q7 k' f
"<td>" + item.getProperty("cost") + "</td>" +
/ j0 u4 B2 m5 |; c# k7 E3 n, m* E "</tr>";
4 n) Z0 Z6 ?6 c2 \& y9 Z}
* j' v5 L& y. [8 @$ b& ucontent += "</table>"; 8 F/ M, S/ D9 X3 t2 W; C" I
return content;
/ D( p6 y" p% e6 G. X
9 r( E: Z4 y+ D/ }5 rC#
, N$ z$ g& p: d" h9 N6 y5 eItem qryItem = this.newItem("Part","get"); " [0 ]" ~6 A! \5 W
qryItem.setAttribute("select","item_number,description,cost");
$ `) d; L: j% b7 m% j9 j+ eqryItem.setProperty("cost", "100", "gt"); ' r2 q6 A! e. B7 X* g
Item results = qryItem.apply();
8 D' R* k! y, @! g5 [+ v5 \/ Jint count = results.getItemCount();
# e. A+ \/ m3 qint i;
9 ?+ J) o0 c5 u) mstring content = "<table>"; ! z- O( H; z2 F! h0 @! l( ]
for (i=0; i<count; ++i) , ^ b! ]. B7 h% Y
{
, ]! q' z& O6 l Item item = results.getItemByIndex(i); ! h9 ]4 s+ B7 i7 ~+ Q5 B
content += "" +
$ F: G; l- K! C# l8 N "<tr>" + 4 Z5 e; [8 l* `/ B/ [9 |8 {
"<td>" + item.getProperty("item_number") + "</td>" +
; v" X% u3 v3 W; ]& k "<td>" + item.getProperty("description") + "</td>" +
: u. f/ S6 S- j: w; u M% g5 e "<td>" + item.getProperty("cost") + "</td>" +
4 U$ Q p2 p7 u( @# L9 ]8 w P "</tr>"; ) h, a/ l8 j/ o( N
} ; y; l) G- G9 z5 J8 {: n! V; _! I
content += "</table>"; R1 X; U0 ^& [# K w: p# k
Innovator innovator = this.newInnovator();
- v2 a( L; p9 ]' dreturn innovator.newResult(content); , e. u) f4 a1 E: l8 _5 H! \! F- T
$ z8 [( X1 y2 p" `+ v% g% _7 g
VB.Net
+ i$ t2 W# m7 u+ TDim qryItem As Item = Me.NewItem("Part","get")
, A4 @2 n; `$ U3 e) AqryItem.SetAttribute("select","item_number,description,cost") 2 U0 Q$ q" R) x/ O
qryItem.SetProperty("cost", "100", "gt")
3 G* X2 A$ g" m! S: NDim results As Item = qryItem.Apply()
% u x, e; x" S% a! c1 |" JDim count As Integer = results.GetItemCount() " w0 M( S( x0 v4 _$ z
Dim i As Integer
/ b5 u$ N+ \) i+ `2 T+ ADim content As String = "<table>" 6 @) L, K7 L( z% z
For i=0 to count - 1
- }3 L+ g: @' c: y6 Z I Dim item As Item = results.GetItemByIndex(i)
# C" o9 s/ E. _" A! N) { content += "" + _ 0 R9 s: I3 n6 \9 L
"<tr>" + _
5 L, P- r, W! ?; H "<td>" + item.GetProperty("item_number") + "</td>" + _ 3 g n. V& K6 k! C2 ]. {* S& B
"<td>" + item.GetProperty("description") + "</td>" + _ % m, ]5 J# \, K( R
"<td>" + item.GetProperty("cost") + "</td>" + _
0 |1 B4 [7 n$ e; X$ d* a1 h "</tr>" ( K3 x/ k0 K4 h% l0 w
Next / a* Z3 S: F) a( f
content += "</table>"
6 j* g& j% L5 K* s$ p* q / E2 G: J. v* f2 x# ?- _ V: {
Dim innovator As Innovator = Me.NewInnovator()
$ l2 J# i6 @: F2 ?return innovator.NewResult(content)
2 \. p4 O7 j4 X9 @. H! O7 y/ u$ F5 }1 J3 e7 F$ M
1 Z: _7 J/ Z! R( p. T6 y8 i |
|