|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, R; Q. R3 k- q& h. j9 v/ n) t1 v4 W
2 P! w5 O# G) J0 i/ M! A
# b( x8 y$ @. F3 s6 e5 r3 U8 U0 o4 H# B5 l' y) F5 i5 K/ s3 }
Technique 7 H* m" t6 P$ S; ^: d& J
There is no difference in setting up a query for a single Item or for many. Only the * \# K6 O' Q( K7 Y
criteria define the set size returned. In this recipe you create an Item and populate
& m9 k1 v$ x6 C. T/ `5 @0 ^0 @the query criteria, apply it, and iterating over the Items returned producing a HTML ) _0 C: z8 u% |
<TABLE> fragment. 7 h: X) y! B9 |& s' p) c
+ j3 ~2 Y- n! ]9 |
' Z; z2 B' q" u0 v. p
JavaScript
( S" _& P( R. ^. p, k- w4 yvar qryItem = this.newItem("Part","get"); 3 y4 a F: R! |
qryItem.setAttribute("select","item_number,description,cost");
6 |7 N) Q4 w$ G# kqryItem.setProperty("cost", "100", "gt");
j+ _/ C& ?& @# Kvar results = qryItem.apply();
# i7 s) p, O& Dvar count = results.getItemCount();
6 o+ k% I' v) R$ o' o" ]var content = "<table>";
" r; r) F; s; }0 L7 I" z9 D9 Kfor (var i=0; i<count; ++i)
$ z* g3 }/ v' l" H{
/ M+ Z" V6 X H/ ^# b var item = results.getItemByIndex(i); $ J+ U1 d$ w4 f) {2 \/ _# q9 @- o
content += "" +
- v# h' D; h0 K "<tr>" +
# V |1 N! W: s) r "<td>" + item.getProperty("item_number") + "</td>" + " }$ W; W' D0 w/ ~3 B
"<td>" + item.getProperty("description") + "</td>" + - i2 w3 z$ J& B! `- a# K2 D
"<td>" + item.getProperty("cost") + "</td>" + : @. g* t. ^ W& U% q
"</tr>"; ) X8 k0 p+ J/ F8 ^7 g) d7 p
}
9 I5 n0 W8 e" f: l _8 K7 Pcontent += "</table>";
$ Z9 `: j) I3 w3 g+ T& Qreturn content;
! X. J, j1 a" S
7 o$ r- h* `* {" g2 a/ f* }3 C kC#
( a5 C# D' N* y5 [" E8 \% SItem qryItem = this.newItem("Part","get"); 5 A" r# i* N5 @9 e
qryItem.setAttribute("select","item_number,description,cost"); 3 o( |! l, O7 a0 \
qryItem.setProperty("cost", "100", "gt"); + s* Q2 b8 f2 ~1 n( @
Item results = qryItem.apply();
! Y+ S) q7 Y0 T; F- Z9 c5 Lint count = results.getItemCount(); k# }# d- x/ |; R% Y% P- q- k
int i;
$ Y1 Q5 U7 r0 @string content = "<table>";
+ p- ?( [3 H' i! Dfor (i=0; i<count; ++i)
) V9 Q" G$ K) y{
! g) J& b8 h. |2 |& r Item item = results.getItemByIndex(i); . w7 m' [; A9 c& v
content += "" + 5 t. U* N; J; _' y# w- i
"<tr>" + / r4 c) s/ G- K/ D0 n) l
"<td>" + item.getProperty("item_number") + "</td>" +
* m3 S0 q& F8 ?/ I. ? "<td>" + item.getProperty("description") + "</td>" + , Q0 d- [ Q5 i4 p2 w
"<td>" + item.getProperty("cost") + "</td>" +
- @" E5 N) N: g4 ~( o "</tr>"; , S/ j, a; H+ L
}
5 U# e. N; u1 b. j7 O4 `; y1 kcontent += "</table>"; 5 o1 g( @4 G& d" H d! |) x% X
Innovator innovator = this.newInnovator();
$ f( P. j$ c D4 H! r2 Nreturn innovator.newResult(content); 8 W9 i/ A8 l! B! L- z4 Y+ U* |2 z
) Y4 U6 h# k+ R' ~! B1 ~# b1 ^VB.Net
' p6 N2 n1 x- A0 ~% |Dim qryItem As Item = Me.NewItem("Part","get") - A _+ W+ Q; I) T9 h
qryItem.SetAttribute("select","item_number,description,cost") 1 e0 f/ F+ }+ \) |/ k
qryItem.SetProperty("cost", "100", "gt")
7 g* m/ A# |1 q" b8 b WDim results As Item = qryItem.Apply()
0 k1 E0 T5 Y' K4 b( n& \8 u' [Dim count As Integer = results.GetItemCount()
& k$ M8 [& G; H2 oDim i As Integer 5 V" r; O; y4 A# s
Dim content As String = "<table>" - B; ]5 _; X# ~: J
For i=0 to count - 1
$ e% w# g& \4 T" K Dim item As Item = results.GetItemByIndex(i)
: x# O h z4 R; G content += "" + _ * U# L+ F! L0 X: j
"<tr>" + _ 3 X4 C% b" w. P Z { j
"<td>" + item.GetProperty("item_number") + "</td>" + _ ) U3 Z& w7 a" A. g+ ~
"<td>" + item.GetProperty("description") + "</td>" + _
- {6 `* S" H8 B "<td>" + item.GetProperty("cost") + "</td>" + _
# l7 `+ Y1 O" F: \ "</tr>" ! `! l$ j; Q# R( y: z) _
Next
# a8 }3 y6 D; k5 i3 F! m5 t+ zcontent += "</table>" ! h' t* Z/ }4 {6 \' p5 n4 _8 A
! v6 f, ]. p% P$ }) c" ] z1 z7 j
Dim innovator As Innovator = Me.NewInnovator()
4 W; s: i" L! Q1 l1 R0 z" a5 jreturn innovator.NewResult(content)
. V. |) f; T3 i$ F2 y# X. ?) w M; A& W# S/ O9 r
) Z' K. z$ o I5 x, G- D3 f |
|