|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 }# f# b* h$ P& q; l, i
4 a' K8 h% G, v7 \
9 [3 Y! F$ v7 D1 g* ^3 j% B, N; n- x0 ~( o* V
Technique
! p" Y3 F: c9 P3 l" L/ b" dThere is no difference in setting up a query for a single Item or for many. Only the 2 F; i) d' M1 a" X
criteria define the set size returned. In this recipe you create an Item and populate
# x) k5 K: q# I* [, P2 nthe query criteria, apply it, and iterating over the Items returned producing a HTML ' U: D% R E4 {, P4 ^
<TABLE> fragment.
) G/ i2 H9 n4 L9 k4 I" |. G" l. m( c, S5 j4 V( Q( s
( H2 n4 D; K+ G# ]* p/ @* d
JavaScript - V6 e1 a9 r' n! L# L) h
var qryItem = this.newItem("Part","get"); 1 u5 s) P) F' s3 e& u6 \
qryItem.setAttribute("select","item_number,description,cost"); ! I, k) P5 e3 ~" A: o! d
qryItem.setProperty("cost", "100", "gt");
4 ] {% U3 B) O5 O0 h' k' kvar results = qryItem.apply(); ' r6 l- E. K3 k: s% F
var count = results.getItemCount();
* R2 v+ r7 x3 {+ w1 K$ p9 tvar content = "<table>"; / U' f# c& V8 o( w$ l# w5 G( L
for (var i=0; i<count; ++i)
2 e# Z8 G* A* i' f ]! J4 n( l: [{ / B8 V8 q( G& j6 C) p
var item = results.getItemByIndex(i);
( } y/ ]3 y; u1 f+ a4 S. Y7 Q content += "" + _' Z+ Y! ^, D3 }6 i% T" _3 p
"<tr>" + ( f+ ]4 R# a% k# ?
"<td>" + item.getProperty("item_number") + "</td>" + 5 `; l+ c6 d& ^5 t0 U
"<td>" + item.getProperty("description") + "</td>" + 7 ?; H% f& d! g% Q
"<td>" + item.getProperty("cost") + "</td>" + 0 N$ D$ S6 n/ q( j* g
"</tr>";
4 p) w; D' F( q, t. E' Z}
9 t" Q1 Y/ L) U4 q! g1 c7 ~7 Gcontent += "</table>";
" B/ a" }7 f3 Z; yreturn content;
3 F: R7 [* N |! {
+ V$ [4 y' A) s! M; F3 BC#
) M( _$ f. a* s4 yItem qryItem = this.newItem("Part","get"); : e0 R" A" G% d8 ?0 K7 L' E
qryItem.setAttribute("select","item_number,description,cost");
9 ]! S, s# q5 _" s" ~8 E9 XqryItem.setProperty("cost", "100", "gt");
9 c; M- \4 |! D P, a- \( G- xItem results = qryItem.apply(); 5 _* [" B r; u' F( F# i& d
int count = results.getItemCount();
: O( ?9 i4 h, i5 q3 hint i;
6 `; M8 e/ r* istring content = "<table>";
- A6 m! r1 o; o% y# R$ Nfor (i=0; i<count; ++i) " }* L6 y0 Z4 i' T, g/ n
{
: |; g7 |3 {7 Z Item item = results.getItemByIndex(i);
' k5 r$ J: ]* X4 N1 R' Z Q$ J9 A( j content += "" +
$ d! f3 _; `$ T7 E& l# [9 `# ~$ G "<tr>" + ' s$ y1 T9 J7 O# E7 M. b' `
"<td>" + item.getProperty("item_number") + "</td>" + # P6 t9 \+ x2 R9 p8 _! |7 W( l6 i
"<td>" + item.getProperty("description") + "</td>" +
q9 U7 K' m4 e/ P S$ S! }0 G/ q "<td>" + item.getProperty("cost") + "</td>" + 9 T( r/ ^% e, s$ z6 O2 |
"</tr>";
, N& i/ L+ X& d! {} 9 [' K" |) n4 x8 D! E0 S
content += "</table>"; * b7 E8 I4 U: R. o- L
Innovator innovator = this.newInnovator();
# z2 K& p$ N" b# u- y3 W% Zreturn innovator.newResult(content);
* w0 d( M/ }3 K% I7 Y. w
1 D- g. H9 u3 z# @3 H( _2 PVB.Net ) T2 q; Y7 J# A- y( x# N& z3 P
Dim qryItem As Item = Me.NewItem("Part","get")
3 k, d/ |% G2 I7 g: J- MqryItem.SetAttribute("select","item_number,description,cost") X4 b2 _' }# N: k1 o
qryItem.SetProperty("cost", "100", "gt")
6 w, J3 y+ f) w3 v+ NDim results As Item = qryItem.Apply() , h4 Q% R" d$ X2 V7 O: H. Q! o; [
Dim count As Integer = results.GetItemCount()
$ i" B% u) J/ }! P$ EDim i As Integer
1 k. ?- d$ J4 M1 {$ UDim content As String = "<table>"
2 @% V7 C! B6 }% A1 v5 vFor i=0 to count - 1 + N5 i$ a* R% o, c
Dim item As Item = results.GetItemByIndex(i) * v H& k m I7 ~2 `
content += "" + _ 8 M. z: C. R4 g0 A
"<tr>" + _
* a! f) j% U" H "<td>" + item.GetProperty("item_number") + "</td>" + _ - S6 ] T/ Q/ S% m: C
"<td>" + item.GetProperty("description") + "</td>" + _ # L3 e Z# ^, @
"<td>" + item.GetProperty("cost") + "</td>" + _
# F: ?( |# R2 Z5 s T "</tr>"
p F, ]1 {( @5 R/ w4 e6 q% gNext
2 [: K! w- r( q7 R$ Pcontent += "</table>"
4 G& ^) ?; {5 G, x' f' \' ^3 R ( g E& {) W5 ]1 R9 E. ]
Dim innovator As Innovator = Me.NewInnovator() 4 C% d4 _0 Y& w3 o0 ?! Z; B" Y0 ^ e! V
return innovator.NewResult(content)
, \$ H) A3 f Y7 N, G! f. \
- G5 t% ^! h: s9 c# V" ^7 G. a6 s8 a( X& F0 Y
|
|