|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 h: B- ^$ E: \4 W- e
* R4 E7 l/ G. [0 V. e2 i
/ t! y, y, p1 w s: J9 e
; E& ^8 y) K# W3 y" iTechnique 2 D+ U: f t, `3 {; M5 F! h
There is no difference in setting up a query for a single Item or for many. Only the
3 ~/ M) h% f' jcriteria define the set size returned. In this recipe you create an Item and populate , v3 `6 v/ @- R" A( Y
the query criteria, apply it, and iterating over the Items returned producing a HTML
; T& t3 ^* J* h* B) Y4 O( d$ S<TABLE> fragment. 1 m. g; g" s8 K6 K; }8 N' G
$ Z! L5 O) I4 |. z2 }' y1 f7 j! m9 t" Z) U" x0 i. A* m
JavaScript
$ Y, `9 r) l z8 X& H1 n Vvar qryItem = this.newItem("Part","get"); u. S. [: [- V+ `* [# r5 B
qryItem.setAttribute("select","item_number,description,cost");
6 z+ s3 Y" C& n ?qryItem.setProperty("cost", "100", "gt"); 4 q( _+ @2 P8 m7 Q R7 q
var results = qryItem.apply(); % c4 y+ Q) `4 X/ n9 Z1 X
var count = results.getItemCount();
! ~/ q# Z+ R$ R. j# I |var content = "<table>";
4 N' N! a8 k4 l( T. \* ofor (var i=0; i<count; ++i) 9 k/ b, W9 U' o7 _0 K
{ 8 p4 b7 Y+ |* Y' b* y
var item = results.getItemByIndex(i);
! Q: V$ z5 v: k9 L8 [( f+ X6 u/ F+ I content += "" + 4 z" l5 Q7 G4 O q! L
"<tr>" +
9 ~& q$ O% `7 p( ~ "<td>" + item.getProperty("item_number") + "</td>" +
4 X+ W2 _8 \+ L% L0 ^& @) q "<td>" + item.getProperty("description") + "</td>" + " h9 @6 B! y5 K
"<td>" + item.getProperty("cost") + "</td>" +
8 A' L, I5 o7 K9 u. Q1 Q "</tr>"; * E# p0 e3 x2 x9 O* }# e5 N8 M; J
}
* c; _' [# b* L; ]2 ?* ?) zcontent += "</table>"; 6 K% G5 g& h5 X' i& g
return content;
' g* Z0 w9 S2 t6 v/ i
, [, P Q2 R5 d( cC# " V+ ~2 X. o- @3 w0 F1 y- N
Item qryItem = this.newItem("Part","get");
2 B/ d" A7 U @. m# I; Q' \qryItem.setAttribute("select","item_number,description,cost"); 4 x( |! ~& u q* c" Z
qryItem.setProperty("cost", "100", "gt");
" m: A$ W' A }6 {( iItem results = qryItem.apply();
& X7 @" P; W2 r# Q( N. q+ B8 d) ^int count = results.getItemCount(); 3 J$ x% }& |& F; _
int i;
. M; r: ^' K; k# N( ~# tstring content = "<table>";
3 e7 \+ S. h" d @. pfor (i=0; i<count; ++i)
6 R% f) }% |8 c( e" c \7 j{
+ U/ C' V4 f3 x' s Item item = results.getItemByIndex(i);
/ r4 p9 Q$ Y1 j" p$ ^ content += "" +
% w3 G' ^ n' B9 s "<tr>" + - d1 C7 W8 c; V0 [5 f; e0 W
"<td>" + item.getProperty("item_number") + "</td>" +
" v6 `! f- y& D6 P; Y& ^6 j3 f "<td>" + item.getProperty("description") + "</td>" + ! s7 B g' \1 h) c+ \2 \
"<td>" + item.getProperty("cost") + "</td>" + 4 C5 L2 D3 S+ _1 I* a- Z$ |7 P% {: Q
"</tr>"; - |/ m# U, x) I: s5 N8 S6 [0 g
}
5 e+ O6 ]. y( y" q4 \& z8 Dcontent += "</table>"; 4 V( U, s! H+ f
Innovator innovator = this.newInnovator(); ' z: y/ r( }2 b, G F) w( W
return innovator.newResult(content); % y" T0 j, j9 D; [0 ]5 m
% M) a$ i1 f5 e0 Y$ m# |! x+ j! h2 AVB.Net $ L z; L, L: |4 @
Dim qryItem As Item = Me.NewItem("Part","get") $ [7 h' z0 j0 g
qryItem.SetAttribute("select","item_number,description,cost")
0 E7 U6 C' V! K/ z3 N2 H; M3 CqryItem.SetProperty("cost", "100", "gt") ' ~8 k, f3 Y7 x, n
Dim results As Item = qryItem.Apply()
5 j- o. _6 o- p! DDim count As Integer = results.GetItemCount()
+ A0 y, C3 N4 R3 p- I* H; W8 G: _Dim i As Integer
0 A9 S1 m1 c/ Q. Y6 LDim content As String = "<table>"
0 q3 k3 F x) ~3 Q W, c8 r9 b( CFor i=0 to count - 1
/ u S. }6 G% a" Q' A$ p Dim item As Item = results.GetItemByIndex(i) / p( H1 O# j4 _( f3 z
content += "" + _
6 U* x9 ? d0 d" `! ^$ }7 ? "<tr>" + _ & N" I$ G" E# ]! H4 i/ P# j
"<td>" + item.GetProperty("item_number") + "</td>" + _ # A9 g( H8 Q3 `
"<td>" + item.GetProperty("description") + "</td>" + _ % k9 k$ s8 s+ a E2 s* R) ^
"<td>" + item.GetProperty("cost") + "</td>" + _
* p0 B; W, ?3 L% V3 Y1 d5 I "</tr>" ! s' W& |. A7 t
Next ) s# ]4 Q- ?5 t+ j }& X
content += "</table>" ) _3 E8 t- ^4 X6 K) K p9 O
4 O/ ?9 K1 n5 E1 t: m: C# e3 B% }Dim innovator As Innovator = Me.NewInnovator() 4 p' ^# S8 D6 E- }! ^3 T
return innovator.NewResult(content)
; M8 v/ T: n( j# a2 s" N9 v! P" l5 ? B5 `9 \/ r9 ~
3 d- H' b l d8 O' u |
|