|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 C* x/ ` W( B$ }) K3 Y L
" f, P- |+ ]5 y2 v$ q7 U. G/ x
. q7 m2 M0 e, D& ~1 P* U' Q) X" q+ x. w
Technique 0 h: E( s7 ] S/ }& p% ~7 I$ Q8 X$ \
There is no difference in setting up a query for a single Item or for many. Only the
3 y- ?) y& W/ W! D) rcriteria define the set size returned. In this recipe you create an Item and populate
( {- k) A7 ^6 l. Z' G, x& Ethe query criteria, apply it, and iterating over the Items returned producing a HTML % _3 R3 J1 U* o6 U$ ]
<TABLE> fragment. 8 g, b, `0 ]3 d9 V
/ K, ^. o9 D" G u$ A
/ e& a: ] p. \- I- }JavaScript
3 f% ] r1 X( e# l. A" uvar qryItem = this.newItem("Part","get");
6 T$ A4 h% I) aqryItem.setAttribute("select","item_number,description,cost");
& o0 z8 o5 {8 x |% kqryItem.setProperty("cost", "100", "gt");
$ V n# F$ l5 L1 E5 mvar results = qryItem.apply(); 1 D; b0 }7 o* z! z
var count = results.getItemCount();
# a# m0 o6 U4 B2 ivar content = "<table>"; 6 w2 B7 b9 V. O9 [
for (var i=0; i<count; ++i) 4 v( a S/ D/ n- p8 o6 x
{
, y8 N5 o( v! b5 O* A6 c+ d var item = results.getItemByIndex(i);
8 Y! h; c3 _/ u3 u% E content += "" + # W! J* U& q- V' Q( F
"<tr>" +
2 n+ Y4 [# @, t$ l# ^) G# p1 V "<td>" + item.getProperty("item_number") + "</td>" + 1 [3 }5 h s9 \1 k! g8 R, U
"<td>" + item.getProperty("description") + "</td>" + - M+ x5 F. H' U
"<td>" + item.getProperty("cost") + "</td>" + . ?- v5 @0 W: r& }6 j$ R
"</tr>"; . y8 `: S- e4 B( m! z' C' b5 X7 [
} t/ t4 u" W2 s2 e. t$ \
content += "</table>"; + \' p$ N: Q8 \* U5 w' i% f+ V6 R
return content; 3 j3 C% z; i# G5 k# S
7 T& \7 w1 T. dC#
3 n7 W9 t: w" ^2 _9 ^Item qryItem = this.newItem("Part","get"); ' g! |' w# [* A* O( L
qryItem.setAttribute("select","item_number,description,cost");
3 l T1 z: d: J2 iqryItem.setProperty("cost", "100", "gt"); " W* E. K% l; ?% D8 V
Item results = qryItem.apply(); / g0 C4 d+ @: Z9 s5 a1 _1 L% c# ~
int count = results.getItemCount();
2 j/ h7 A: w4 l7 F& [int i; " e1 h. t2 }; u+ m
string content = "<table>";
! f, B. N) W$ G1 A6 sfor (i=0; i<count; ++i)
- r# a! K/ W( O0 a2 z# K5 p{ 7 l. J2 a6 ?; l% k7 O( M: m
Item item = results.getItemByIndex(i); 8 k& ^: g; f) a8 y f, A8 a" {
content += "" +
6 k6 q" L+ L% o+ D9 I "<tr>" + . b6 J! O m$ J/ e2 d
"<td>" + item.getProperty("item_number") + "</td>" +
( I+ W8 u- h. R- @ "<td>" + item.getProperty("description") + "</td>" +
; e9 w f& w% [: Z: b: |8 X6 L "<td>" + item.getProperty("cost") + "</td>" + 1 p4 ]1 d8 D; ], x L
"</tr>";
. n4 W- N$ Z3 X} , }3 A! {3 a0 v2 J3 O' d* u; t
content += "</table>";
7 {4 G& u0 p zInnovator innovator = this.newInnovator();
6 R( q) O$ ?1 U% f- f+ dreturn innovator.newResult(content); % Q3 D; F" m( y( S
9 n& e. I- L* W9 o L
VB.Net ) |( D" H5 l: H
Dim qryItem As Item = Me.NewItem("Part","get")
5 ?; s9 X* |- @qryItem.SetAttribute("select","item_number,description,cost")
8 }1 E% F/ R6 w; @4 TqryItem.SetProperty("cost", "100", "gt") 1 B6 N7 Q3 O0 i6 n
Dim results As Item = qryItem.Apply()
2 |) c7 ~& S }7 |: a; Z0 oDim count As Integer = results.GetItemCount()
) \% f: o. ?/ F4 O) l4 ^! R; n6 r* YDim i As Integer 6 O; X% Y: B4 k/ t" e6 [3 [. w
Dim content As String = "<table>"
$ i. x) M6 Q. e% p; k2 cFor i=0 to count - 1 ; D! y5 B. w. @: J. {
Dim item As Item = results.GetItemByIndex(i)
0 C, b$ o- K) p# c content += "" + _
+ G9 E$ r* K' I* u, K L "<tr>" + _
; u2 T) u( `1 C5 y "<td>" + item.GetProperty("item_number") + "</td>" + _
% @, H. i" U! w2 k2 d* C "<td>" + item.GetProperty("description") + "</td>" + _ 4 T/ h7 y/ F5 c# M
"<td>" + item.GetProperty("cost") + "</td>" + _
0 r: o2 T/ V" w "</tr>" $ F% l+ X/ ?5 \
Next
+ J6 ~5 y/ c o! Kcontent += "</table>" / ~7 a2 J* i7 j' H% b2 Y* `
" _3 _$ x+ ^6 r7 W1 SDim innovator As Innovator = Me.NewInnovator() # v# \# l" J/ ^: O9 f9 t
return innovator.NewResult(content)
1 }' v; {. [' O! E% Y# e6 M+ \2 f7 `. g! G* `* [8 T. N. ]
2 m( J$ w' A9 g2 s; l9 D/ Q, ^3 U7 m |
|