|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 ^7 m. a# U9 J2 ]% }" k- ~' J6 c2 T
0 t x$ K; Y0 |
% G$ N1 ~" O# \- FTechnique + L* J! Z' h: k1 q5 W
There is no difference in setting up a query for a single Item or for many. Only the
& G: y) \" f$ a& g4 H( Wcriteria define the set size returned. In this recipe you create an Item and populate 7 F2 m$ S, ]% t
the query criteria, apply it, and iterating over the Items returned producing a HTML
D( T: Z1 Z/ ` v<TABLE> fragment.
8 J$ ^6 n$ L0 o8 c8 ~3 F& n3 N+ d$ S
; q' ? B. ^4 h6 B/ p0 c) n$ i
JavaScript 0 p5 S& Z$ E) m$ J8 d
var qryItem = this.newItem("Part","get");
+ Z4 R4 A* s2 {2 H) X9 F9 ~/ k: TqryItem.setAttribute("select","item_number,description,cost"); - M5 }* u& H4 p
qryItem.setProperty("cost", "100", "gt");
1 i }( O4 P$ fvar results = qryItem.apply(); - u! K! X; f/ Q; X3 G: \) p
var count = results.getItemCount(); % O& T) ~. O2 E- d9 }
var content = "<table>"; 3 U) P/ z1 [! I8 d# \! B
for (var i=0; i<count; ++i)
3 [4 B3 C9 T& D8 G4 p$ x{ + X- P9 h/ A: e, H
var item = results.getItemByIndex(i); ' g9 w3 O, H6 K; M" A; \2 X N
content += "" + 0 x: o- @+ q: r: e. _
"<tr>" +
( I/ h: I0 Z' H+ j "<td>" + item.getProperty("item_number") + "</td>" +
, V& f# N# A% i( l3 K; ~ "<td>" + item.getProperty("description") + "</td>" +
+ l% l. r5 v- z( L "<td>" + item.getProperty("cost") + "</td>" + $ ?9 ]2 A+ Z( E% P5 v
"</tr>";
# P! R. h- i; I, ~- b8 b} / j E v' v$ C$ }6 I
content += "</table>"; 6 _ ]$ z2 k- C: V% x' G
return content;
6 F; _. j1 ~4 v Z4 L2 G( m
1 [$ o9 @: @6 [# bC#
' L6 y. F, d) V2 x" UItem qryItem = this.newItem("Part","get");
3 N. Z6 a& D& e9 O: h/ |qryItem.setAttribute("select","item_number,description,cost"); . O% y3 @% x- X/ R0 A
qryItem.setProperty("cost", "100", "gt"); * ]0 d) B# c j5 E/ j6 z
Item results = qryItem.apply(); - p7 |4 x! b" x/ b* [2 Y
int count = results.getItemCount();
' {+ R7 K$ a. Q; d+ pint i; 6 v4 J" @4 R6 ^) h1 c% q" {
string content = "<table>"; 2 s& ^4 q2 o0 t8 ^. M* T7 P
for (i=0; i<count; ++i) 9 ~- |. c) E0 y3 l
{ ! L+ W( d5 x( m' W$ X. ?. M5 n% _
Item item = results.getItemByIndex(i);
+ N' s8 E1 b; X" W6 L content += "" + 4 l6 z- E# F* y( N0 y
"<tr>" +
8 w- q$ o9 i/ F# ?! S; j: [; r "<td>" + item.getProperty("item_number") + "</td>" + 9 {% h* }/ T$ X( W5 \! p
"<td>" + item.getProperty("description") + "</td>" +
j: \' s% x3 M "<td>" + item.getProperty("cost") + "</td>" + ) g2 Q, p% K; N) x$ @3 o
"</tr>";
- ]2 I8 V2 L5 C$ n) K}
7 G. P2 }+ ?8 ]5 W2 @0 A( Ncontent += "</table>";
+ m. C* |" ^ s6 A( {Innovator innovator = this.newInnovator();
( `4 t& {) R" ~0 ?6 k+ m/ u! ], Freturn innovator.newResult(content); 6 O/ P8 o: Y5 U/ t8 O
. D; [: X% o$ M1 M+ [
VB.Net % k7 b+ C# ^; D+ S) d: @
Dim qryItem As Item = Me.NewItem("Part","get") J: L* D! z/ Q7 G6 C- P# e
qryItem.SetAttribute("select","item_number,description,cost")
7 f& Q- F+ M$ w" e% p5 j! e7 kqryItem.SetProperty("cost", "100", "gt") , c4 v, |& h* n v
Dim results As Item = qryItem.Apply()
: y2 P' | V! h; p9 jDim count As Integer = results.GetItemCount() , V. r! u( D7 o# J
Dim i As Integer
: L4 U9 h! u7 P% M: r; B. j6 HDim content As String = "<table>"
: O+ w$ `8 f$ n& q2 T5 sFor i=0 to count - 1 . D! ]% r# P0 n r; S
Dim item As Item = results.GetItemByIndex(i) 8 [, j i0 C& z$ M6 R7 R' z
content += "" + _
1 N I' i1 k2 a. f) _5 m( @ "<tr>" + _ / a; a5 _; j: J; w) q: v2 s/ l7 U
"<td>" + item.GetProperty("item_number") + "</td>" + _
7 r* u5 t( c# Y; ? "<td>" + item.GetProperty("description") + "</td>" + _
: Y* l/ H9 u/ z) X+ R "<td>" + item.GetProperty("cost") + "</td>" + _
4 m, l+ | l; A T' u' C- ` "</tr>" . ], {: t3 k$ |6 M( O7 K7 S
Next ) N+ ~! n7 o+ R- k# C2 u0 i
content += "</table>" 9 M5 l" i" L# l+ K
, U, |+ V8 q w2 ^% k) k( ]Dim innovator As Innovator = Me.NewInnovator()
, o9 m- D3 Z& D ?+ \5 {return innovator.NewResult(content) / v, y3 e- E3 n) p
. D V; s5 L: n
+ [ @' A5 Z' J |
|