|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- p) W9 U* C9 v4 i* c
2 O g- p) P! c* B }
5 B* J+ n; `+ Z+ D7 _' P6 {1 m
5 b$ W6 t; c. B$ S
Technique " _. L% c1 ~' B( u9 _# x7 T1 d- `, w
There is no difference in setting up a query for a single Item or for many. Only the
: V1 s- c6 Q# M" M. Ecriteria define the set size returned. In this recipe you create an Item and populate
( v1 f. R2 Z% E8 g( E' p% ?9 g1 xthe query criteria, apply it, and iterating over the Items returned producing a HTML
- m- L c7 G$ M4 q0 \# a<TABLE> fragment.
8 w* I0 ^7 S3 ?5 |2 i; P9 y( d3 C9 h% _0 D
+ {6 `+ w7 N# K
JavaScript ( J& W" L: h) t) b D* l3 r2 r
var qryItem = this.newItem("Part","get");
" g8 y0 H4 T+ R2 \" [0 IqryItem.setAttribute("select","item_number,description,cost"); 0 a& G! u2 L$ W) Z" l) m# k- F
qryItem.setProperty("cost", "100", "gt");
' ]7 v# H6 a. I8 O4 n1 W/ Zvar results = qryItem.apply(); $ n8 ~; L2 \) C1 Q: [% e( ^1 `
var count = results.getItemCount();
) w2 A0 [! P# b1 O$ e' @2 gvar content = "<table>"; , O7 h' ]% L+ s$ Q% x3 G, X
for (var i=0; i<count; ++i) ; j% t" P7 w8 `9 V9 g z
{ % Q5 j4 D9 ~$ p# A( R: O, c% P9 w. I
var item = results.getItemByIndex(i);
! _' \& l3 N' `! m# M/ K. D content += "" + / \' z. E& [( h7 i/ }( h' l
"<tr>" + ) O: n6 U# J2 D: ?' h
"<td>" + item.getProperty("item_number") + "</td>" + d2 L, o6 u* |% U- }6 F
"<td>" + item.getProperty("description") + "</td>" +
" l: Z4 J) R9 X( C' V "<td>" + item.getProperty("cost") + "</td>" + $ b5 \* i, |/ V3 X# f. T! H* H
"</tr>";
9 O9 K' u( ^5 ~2 Y; ?; E- J$ t} # i$ _8 ^7 Y! c1 S7 q5 y
content += "</table>"; 1 h$ z. N# X% c6 E! {
return content;
9 e0 T" }+ k3 V3 ` 1 r) @9 j+ S1 n# j) j$ ^3 W2 q+ I
C#
- G$ {! s7 H3 uItem qryItem = this.newItem("Part","get");
* Q3 p. t1 u' F0 e5 b8 S6 lqryItem.setAttribute("select","item_number,description,cost"); ! M8 i. N; u, D) Y
qryItem.setProperty("cost", "100", "gt");
. T8 O& S) \4 L! `) fItem results = qryItem.apply();
+ e- ?& N7 U+ A0 cint count = results.getItemCount(); * p5 d: }: e8 b# t w$ i
int i; D+ q2 F/ w" F& O
string content = "<table>";
, W+ N5 J8 R4 W4 T1 g6 a' L. zfor (i=0; i<count; ++i) " `" B0 o( h q) C" |
{
8 \) G" i% h! @; _( Z2 d+ p8 g2 S Item item = results.getItemByIndex(i); 1 B/ b# j$ m. x0 O- O
content += "" +
i5 {3 `4 \. h7 p; d "<tr>" +
) W) L" T6 v. u% _2 Q+ C, R "<td>" + item.getProperty("item_number") + "</td>" +
: J1 N# X! X+ e. i "<td>" + item.getProperty("description") + "</td>" +
' ]" e7 A: F) Q: E. S# H "<td>" + item.getProperty("cost") + "</td>" +
# e }6 x' Y# [ "</tr>";
( g3 p6 D# R7 V9 C$ |3 c3 u} 4 E3 X/ }, y; j) {
content += "</table>";
c" l1 c$ x7 gInnovator innovator = this.newInnovator(); # h: D% `4 E( a% U( | z" V8 H! \1 p
return innovator.newResult(content); $ W' H( g; s8 S; `1 R1 t
+ o: y; O) `7 H/ M H8 |VB.Net ) {/ V. |0 O4 m K' H
Dim qryItem As Item = Me.NewItem("Part","get") 2 g9 M/ I+ x3 l+ J
qryItem.SetAttribute("select","item_number,description,cost") 0 A: o* N6 O* ]+ n, t/ N
qryItem.SetProperty("cost", "100", "gt") ( R6 _2 p& s. F5 ]5 m9 L- I
Dim results As Item = qryItem.Apply()
- t/ `$ b+ [- r* i# m2 {+ V. ZDim count As Integer = results.GetItemCount()
& x( s- e3 }, gDim i As Integer
2 e; n* y+ K2 V8 \' t4 o* `Dim content As String = "<table>"
- h* _0 ^2 m$ nFor i=0 to count - 1
! Y. [) d, w9 ]' t* `7 l Dim item As Item = results.GetItemByIndex(i) : P: R( F6 R3 \/ S' O
content += "" + _ % d- ?5 ?' i. M& p8 I3 G$ W
"<tr>" + _ 0 ^" f8 S7 f; c9 d6 q0 i( L
"<td>" + item.GetProperty("item_number") + "</td>" + _ ( x! ?/ T- K1 {' p v$ }+ j$ F/ i
"<td>" + item.GetProperty("description") + "</td>" + _ + Y' j0 F' `+ B$ h% z: R3 S. T
"<td>" + item.GetProperty("cost") + "</td>" + _ % P2 [$ z( Q9 J0 Q
"</tr>"
1 ]7 ~+ h' g+ i: u; {Next
4 U- k0 g# t& ~% h4 r' h1 Ncontent += "</table>"
+ ]$ X, l- `* p/ U 6 T( [: b" Q/ d ? H8 @
Dim innovator As Innovator = Me.NewInnovator() $ z( r0 K. E/ G2 @
return innovator.NewResult(content)
9 x0 Z& G& L- h: A) v' R6 |$ ^
" g& @0 E6 W+ S) ?: H/ A3 E) a
|
|