|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 o3 l5 z* o3 C1 l3 g
* ]9 k& H5 ]4 h0 e/ O% g
4 Q$ @$ H- x0 l. u" t3 o
; m! G, M4 w& U; e+ e7 cTechnique 7 o7 X& _5 e% j, L/ K" A9 n7 n
There is no difference in setting up a query for a single Item or for many. Only the
$ {+ [5 a7 {9 R; Q- k- Ecriteria define the set size returned. In this recipe you create an Item and populate ( |! f( S4 h' \& s. ?
the query criteria, apply it, and iterating over the Items returned producing a HTML
0 V2 D' E6 v4 I d, v. t ?( r<TABLE> fragment. : ^ t, l( e3 Z
2 ?( u% k% Y6 }) f0 H& m E
V/ k A% d9 U8 K
JavaScript
. Z$ C T ]) b: q1 D+ W) Gvar qryItem = this.newItem("Part","get"); % a1 z/ j3 y/ f% d
qryItem.setAttribute("select","item_number,description,cost");
5 V; h8 e7 g: c" R0 zqryItem.setProperty("cost", "100", "gt"); 3 k8 q: e* V7 J0 V- d7 `) O) U
var results = qryItem.apply(); 0 m- Z% f0 d/ e O+ I" D
var count = results.getItemCount();
- c1 C3 O/ v; k- y" ?# Wvar content = "<table>";
. p) y# q) y5 E! g' Q: j7 c" b) z$ rfor (var i=0; i<count; ++i)
, `9 N: D0 p* Q1 Y. _3 G{ $ o9 V" p: |6 Y6 E' r' u. B# ~
var item = results.getItemByIndex(i); 4 u& A6 L0 H/ M) {* `
content += "" +
; T- j. \) _- {6 D "<tr>" + 1 ?: c D5 P6 k/ f$ }
"<td>" + item.getProperty("item_number") + "</td>" +
/ j* M& k5 H, A& u "<td>" + item.getProperty("description") + "</td>" + $ X8 S% ?- D3 B1 P* T" [
"<td>" + item.getProperty("cost") + "</td>" +
4 D3 b; ]7 m6 i: ~8 p4 i "</tr>";
) @" L0 T1 `& u+ e& ?3 Q} ; g0 U ]3 V) {! e
content += "</table>"; 1 T6 i x8 Z+ A9 T/ {" r# L
return content;
7 }- m0 u F9 T& R$ E8 H0 E: `: F
) s! L) b. s4 R5 ~$ K' X+ |1 ZC#
2 B7 v& X, d% ?; U' TItem qryItem = this.newItem("Part","get");
: V1 `. ?) _. I. z/ N9 P w1 t1 ~6 nqryItem.setAttribute("select","item_number,description,cost"); 6 k6 W' @$ {6 a8 D) o" Z) G5 H3 Y
qryItem.setProperty("cost", "100", "gt"); % e. \+ H( P% C* r. {1 ^; ~
Item results = qryItem.apply();
6 h4 Q9 n; c& B9 rint count = results.getItemCount();
1 Z' a8 O+ s( @- F+ d/ Y' ~int i;
! @$ d4 F; y( h. C6 o' a: ^string content = "<table>"; & D: U" t$ j9 {+ s3 X0 E+ H
for (i=0; i<count; ++i)
/ I; G( e$ A* ?{ " ^- }( t) c2 ]7 S
Item item = results.getItemByIndex(i);
; F7 K# j& b/ n content += "" +
% P+ u- v/ _% T4 _) C6 u "<tr>" +
7 z$ V( A) ]" q8 S5 n( Z0 g- d/ z% o "<td>" + item.getProperty("item_number") + "</td>" + . p; B, i8 l! _5 O
"<td>" + item.getProperty("description") + "</td>" + * h, a$ I, z0 @; K
"<td>" + item.getProperty("cost") + "</td>" + * Y! z; {! X5 @( P5 N! F
"</tr>";
9 J0 z N" |# {2 Y3 V} 5 w+ P% s! H( d* F4 o# I: O
content += "</table>";
( \: q( e2 Q5 ]Innovator innovator = this.newInnovator();
- j: l3 P2 L! G5 f; o' q& ureturn innovator.newResult(content); % y$ J3 F6 T4 ^ n1 A
+ N2 n0 B: r+ v b# J; H
VB.Net
" I5 `! K* O$ TDim qryItem As Item = Me.NewItem("Part","get")
6 I% l' w4 p6 U" ^qryItem.SetAttribute("select","item_number,description,cost")
' t8 k2 d9 R# L/ g) CqryItem.SetProperty("cost", "100", "gt") 7 ?) b& v7 K7 Q7 a S
Dim results As Item = qryItem.Apply()
; S) U$ _9 r, @' }! U& WDim count As Integer = results.GetItemCount()
" c* q5 ^3 N+ M- \6 N5 C8 XDim i As Integer
- D7 d8 B: V. y6 h$ IDim content As String = "<table>" 2 ~$ {; Q* t% {
For i=0 to count - 1
% t# l1 u' }# Q J Dim item As Item = results.GetItemByIndex(i)
, z* F6 y( R6 _4 Q content += "" + _ . U( ?! G, h$ D; I1 v
"<tr>" + _
: ~: a. {' m; q3 K/ O1 S "<td>" + item.GetProperty("item_number") + "</td>" + _ 5 w- w ~! e$ g! j$ y& b5 E8 ?
"<td>" + item.GetProperty("description") + "</td>" + _
- @1 c0 U" r d- | W* E0 W "<td>" + item.GetProperty("cost") + "</td>" + _
# \% I& R C! c8 ~* z "</tr>" , `8 y/ V/ |- N4 w3 O! v, e) `
Next {! \* W" o2 n0 V
content += "</table>"
) X8 ^; d7 }$ g $ |* v, E$ t0 f8 l [% B' |
Dim innovator As Innovator = Me.NewInnovator() ; X4 O" y; t- Y2 |: @. V7 T1 I* w
return innovator.NewResult(content)
7 |' b6 [- x: T1 n( g1 K2 q4 E3 w8 ~: W( p0 n' Q
4 U5 K) e# c- s4 p1 w
|
|