|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 p m- a7 ?& N- p; |) @+ P2 o& k7 z5 d/ C6 i
6 {5 c* q+ q8 ]8 k4 o, _8 z3 L( [0 Q: m4 G6 {
Technique
1 x) ?, t f7 l1 L: PThere is no difference in setting up a query for a single Item or for many. Only the
' W# B( W2 ^ ?- x0 V& v" D9 icriteria define the set size returned. In this recipe you create an Item and populate
3 V |4 b0 O" f( uthe query criteria, apply it, and iterating over the Items returned producing a HTML
! K0 s- m! [( A8 g& T<TABLE> fragment.
3 ]! o+ U0 V4 m5 |- f) E0 ~7 a+ z3 W/ ~0 n
% @# s9 E- k- ~. A7 sJavaScript $ q2 n; z# ~+ g1 F Q, K5 n
var qryItem = this.newItem("Part","get"); / g5 g7 B H% \) S0 D
qryItem.setAttribute("select","item_number,description,cost"); 8 j* Z3 E2 H" M2 S) ^8 a! F
qryItem.setProperty("cost", "100", "gt"); ! Q; a- t/ Z6 B: W0 _; G5 B
var results = qryItem.apply(); & u. b1 y9 j4 {4 f9 k
var count = results.getItemCount(); 0 X4 Q$ k" t$ `4 C# u+ n1 J7 e9 Z
var content = "<table>"; 2 Q ]+ n, D) m% i5 T8 z- h' W
for (var i=0; i<count; ++i) % ?) R: N/ g( x3 f3 p
{
' s! f7 P6 ?% B3 ~4 p0 X! y var item = results.getItemByIndex(i); : m# V3 `& N5 ~4 m3 g6 r- K* w
content += "" + # \& j) J# I6 F! t
"<tr>" +
6 q7 h5 V) M9 O. {* V "<td>" + item.getProperty("item_number") + "</td>" +
4 L8 [; ?' R% V" G "<td>" + item.getProperty("description") + "</td>" +
; o7 ~5 S2 Q4 F3 F. L "<td>" + item.getProperty("cost") + "</td>" + % D1 ]2 d7 v0 j7 Q
"</tr>";
: v2 O- C8 B' c/ o3 M( P+ s} " \1 B" p% {% f; p9 @: X9 ]
content += "</table>"; 0 n e' A3 ]% W9 z* ^0 d( e5 d# F
return content; , n7 O/ H n2 d- g8 R) L# S0 v
' x8 T7 J2 e5 ` M7 y# u' b. C
C#
- r* m% d# o. qItem qryItem = this.newItem("Part","get");
. C g q; M5 r7 }, [% W3 s9 LqryItem.setAttribute("select","item_number,description,cost"); ) s/ s$ p% w0 D3 J" M
qryItem.setProperty("cost", "100", "gt");
! p0 {( h" e- }Item results = qryItem.apply(); - |5 o! l( _/ B- E& |) ]" G3 ~. K
int count = results.getItemCount(); 3 B, \$ M. L! j' S# Z; g0 J
int i;
! K$ Q0 o4 P9 i! v3 astring content = "<table>"; / ^+ m" f1 d2 Y; e' w+ F1 |
for (i=0; i<count; ++i) - ?( Q4 H9 t3 D! d
{
7 W1 C4 B- r2 Y1 L Item item = results.getItemByIndex(i); ( o S8 q; E& e5 u) n' D$ @+ ^
content += "" + 6 B. Q; X$ e# n! G; D- j
"<tr>" +
3 f& r& a# M! b( c6 r7 E3 N1 ?1 @/ C "<td>" + item.getProperty("item_number") + "</td>" + , V) S& K$ w1 q6 D8 p
"<td>" + item.getProperty("description") + "</td>" + 6 Y- K' U' m0 o+ F% |' H
"<td>" + item.getProperty("cost") + "</td>" +
1 W8 C1 H4 \7 X9 G "</tr>"; 2 Y& Z) T5 D& c4 Z! X
}
/ t, L( Z3 Y) f, Econtent += "</table>"; ; K+ \2 w( S5 L
Innovator innovator = this.newInnovator(); ! m. ^8 y+ M+ Y, S" h
return innovator.newResult(content); 7 L- V% B8 ^ x1 L# |7 k. b( E
8 [% g+ M) J7 A+ K( F
VB.Net
; q; I+ Q, F4 ]* T7 LDim qryItem As Item = Me.NewItem("Part","get")
& W& `& z' F" v; _% M- |qryItem.SetAttribute("select","item_number,description,cost")
7 }" d8 O& _' H+ J1 ]3 xqryItem.SetProperty("cost", "100", "gt")
5 p9 f( I( o) x0 hDim results As Item = qryItem.Apply()
+ x- x5 Y' } EDim count As Integer = results.GetItemCount()
8 p" E1 h; ~3 e6 Q, WDim i As Integer
% C. S; g6 C6 I" H3 q3 m3 r& qDim content As String = "<table>"
: J, k& w2 C0 \+ M8 N" gFor i=0 to count - 1 6 M* q9 f3 F( k% E7 m1 B
Dim item As Item = results.GetItemByIndex(i) ! S8 T6 H$ ~5 C& }2 b* c
content += "" + _
( b# T& Q* f, S* _0 R' H1 q, o o "<tr>" + _ 4 u5 C; C5 |8 X/ Z' M3 y u
"<td>" + item.GetProperty("item_number") + "</td>" + _ 9 s, F; f: U: @/ S& X# h: W& |( L
"<td>" + item.GetProperty("description") + "</td>" + _
/ M/ h1 _6 k; _" F) X+ I9 C "<td>" + item.GetProperty("cost") + "</td>" + _ # i7 q8 b' i! ?; M
"</tr>" 1 U6 o! e8 ^# @! Q
Next
; E- X7 }/ Q6 P' ucontent += "</table>"
9 `( s. G" L- r
. `7 n7 x- S$ I0 lDim innovator As Innovator = Me.NewInnovator() & v1 W8 X7 \; v( `
return innovator.NewResult(content) : U p- x" {: H2 s- e6 e5 O
/ F( e: h. m0 _- {3 f
/ W$ t2 f0 c' X! A |
|