|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- t7 y9 f+ L7 E, B! X% t
. r$ c& | b1 O- O5 b1 |- B: S: ^8 q) T3 P4 W
7 g" _3 X6 H! G' PTechnique ; v7 H- X$ t& h ^$ K3 U. G
There is no difference in setting up a query for a single Item or for many. Only the ' L% `/ o) ]2 a9 `4 A# g
criteria define the set size returned. In this recipe you create an Item and populate ) m6 A b) e$ n: H. O) S
the query criteria, apply it, and iterating over the Items returned producing a HTML - Q! G2 f# b" X7 {
<TABLE> fragment.
! _. H5 [; O0 q1 Y l! N4 P* o" I3 N1 t7 y6 E$ |
7 e: t1 T# t2 i5 Z) R
JavaScript
4 M( _3 m% B% @( E1 d5 Evar qryItem = this.newItem("Part","get"); & k3 V6 Y1 g1 e! d
qryItem.setAttribute("select","item_number,description,cost"); & k% U/ |% w3 F4 ^" R: s
qryItem.setProperty("cost", "100", "gt"); 1 J& z- R" ~6 W) S" n! r' C% ~3 l! [
var results = qryItem.apply(); 3 H: G$ B/ L A- s/ | ^6 P7 h5 e
var count = results.getItemCount();
. f/ B5 |- @! w: Evar content = "<table>";
a8 q6 w4 S" F- Cfor (var i=0; i<count; ++i)
* K+ {/ I4 E# p. ?& L2 _{
. |/ W$ y1 Z( r6 M) b var item = results.getItemByIndex(i);
+ x# D% k$ s$ d5 k content += "" +
& q4 a2 j/ Z( k' f' s! I4 b1 }7 c "<tr>" +
5 H2 U" k0 T# e8 t) t' ]' G q "<td>" + item.getProperty("item_number") + "</td>" + A* N3 k$ ?9 P- [2 J# O
"<td>" + item.getProperty("description") + "</td>" + * ^7 g, U% z$ Q g2 K, ~* K$ w
"<td>" + item.getProperty("cost") + "</td>" + 4 r4 l: ~+ t% P
"</tr>"; 3 j" x* w$ ^' |' Z
} 5 E6 d/ E5 U% b- k, S% X& k3 }! n6 Q2 L
content += "</table>";
; A+ Y' M4 a8 q/ Hreturn content;
. v; X5 s5 I% W" s6 Y( w * c; e! [2 ~' q; P- I# E5 o
C#
: I! B/ Y- ^8 nItem qryItem = this.newItem("Part","get"); * Z" x: ~0 ?6 w4 i; c5 T; {
qryItem.setAttribute("select","item_number,description,cost"); 0 w% |2 X& x' N( v& e x3 A; R
qryItem.setProperty("cost", "100", "gt");
. D) K5 k' E! f/ z' uItem results = qryItem.apply(); ; s" W, a: ?* F9 S9 G" B
int count = results.getItemCount(); 4 }, j$ }4 l# w; P- e% i% j4 s
int i;
4 D! ~! _( s5 o' Hstring content = "<table>"; ; P0 S5 e5 z) ^, i4 j
for (i=0; i<count; ++i) 9 _8 p5 ]9 a/ m: R
{
: M4 n. A* O" ]) p5 K/ I- ~/ c Item item = results.getItemByIndex(i); ( D/ t' x' J% @4 h
content += "" +
. h9 X7 p5 g6 O: g0 E "<tr>" +
; S0 K* C, }, d0 u- G" ^ "<td>" + item.getProperty("item_number") + "</td>" +
( [& t8 r3 u% @. b "<td>" + item.getProperty("description") + "</td>" +
2 T, k: I( S0 h" a6 O7 `+ ? "<td>" + item.getProperty("cost") + "</td>" +
0 h' r( Q+ T+ ^( Q# `# H m7 R7 U "</tr>"; * u7 J' b) O; n
} . b8 h" X4 L* }. R, y7 p J0 q
content += "</table>"; " b; K, L& R+ P+ _6 U2 H4 T
Innovator innovator = this.newInnovator();
5 `7 I5 d4 o/ h! `' T/ ?5 Lreturn innovator.newResult(content); 7 @0 K8 f/ ~9 B X7 z) [
' C* K/ T3 o8 B) y3 n& vVB.Net
8 F7 b2 L( y1 a' WDim qryItem As Item = Me.NewItem("Part","get") ! y6 ~# s8 y$ _8 G: X+ d
qryItem.SetAttribute("select","item_number,description,cost")
; l! o2 `9 M; s) }( {& n5 VqryItem.SetProperty("cost", "100", "gt") k5 V6 K0 p4 K
Dim results As Item = qryItem.Apply()
& R4 l, r$ Z2 u3 cDim count As Integer = results.GetItemCount()
- Z9 t, d( t1 \1 g1 |: _Dim i As Integer ( I ]' ]; K' p$ ]
Dim content As String = "<table>"
4 a- y/ ^* \4 E gFor i=0 to count - 1 9 i, Q7 R$ p( u3 |! K2 V
Dim item As Item = results.GetItemByIndex(i)
0 x2 [& a! C! F3 o content += "" + _
! ~1 m6 w8 X% z "<tr>" + _ 2 ] H6 I) V* }' k
"<td>" + item.GetProperty("item_number") + "</td>" + _ % g* g+ H) l' r; V5 q" s
"<td>" + item.GetProperty("description") + "</td>" + _ 0 y A6 h* ]! n5 k# U9 D& v
"<td>" + item.GetProperty("cost") + "</td>" + _
. ]' R3 F7 ] E. r) ^' W' {) W "</tr>" " h) Y4 i" h+ C. z$ E) }* e& m2 D
Next . K( [, F! O& X9 M9 a$ s9 p( L/ o
content += "</table>" 7 t/ _5 Z. F9 x; s/ R3 K6 N$ |0 a7 P' O
/ d5 ~/ b3 j6 L6 X
Dim innovator As Innovator = Me.NewInnovator() * n! f' G& r) [9 ]
return innovator.NewResult(content)
0 ], M: T3 ^% L+ o( `9 A; w' p) y+ K: b( t5 L+ w
b* ^( m' d3 D: h |
|