|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ M" w4 J, i; g: v3 l% W9 D& k' p
* \5 Z& H o/ e& }; T3 p! o( z* C% J/ J7 ?
2 c [& s% E9 I: f1 gTechnique / V& `3 y. D; ?+ t( }& K+ x
There is no difference in setting up a query for a single Item or for many. Only the
" Q5 `- ^9 w, |2 y! M3 g3 y5 Ncriteria define the set size returned. In this recipe you create an Item and populate
' v5 ?: s$ ^+ n( d/ |3 S3 u3 Lthe query criteria, apply it, and iterating over the Items returned producing a HTML
; ?( f" k# D r- b+ {2 b% f5 {+ ]<TABLE> fragment. 3 v$ _4 U! c) {7 l+ j( l' ^
[1 q" v* E' D& C4 V* d& ^: J1 D& h: z; U8 C0 n
JavaScript
0 x- j. } M$ n4 s N. L' L* f+ Fvar qryItem = this.newItem("Part","get"); 7 K; |" K; t0 K4 _( L
qryItem.setAttribute("select","item_number,description,cost");
) Y, X, k/ F, H6 LqryItem.setProperty("cost", "100", "gt"); ; M- \% F7 U. `; O& T5 H4 d0 c
var results = qryItem.apply(); $ @2 I" m# _) K" K9 c" {
var count = results.getItemCount(); 6 M6 M: v- T+ E
var content = "<table>"; 8 v/ }, [/ t+ E/ i1 U
for (var i=0; i<count; ++i) 0 ^, T+ j0 d, `- F J$ |4 S
{ - r1 y: b5 f: P! x" \1 T& d
var item = results.getItemByIndex(i);
' v, a; J' ~* X4 Y) f8 N content += "" +
# M. `0 a; H7 u8 z% p/ M6 m "<tr>" + 5 L$ b. ^9 w' i5 _
"<td>" + item.getProperty("item_number") + "</td>" + 9 g7 l% I& S4 q
"<td>" + item.getProperty("description") + "</td>" + 1 C. K* t- d( ?9 B: P' R6 s
"<td>" + item.getProperty("cost") + "</td>" + ' q8 {: | N# A/ `' V U& P& |, r
"</tr>"; 5 T6 c% q. R {6 Y
}
: A5 V/ @" q2 H- w1 Fcontent += "</table>"; " u M9 @8 R8 D
return content;
2 h* ^9 y2 ]% O6 C7 I f
7 a2 {1 t2 _8 \6 AC# ; D& L5 Q" X$ }7 }! q, q
Item qryItem = this.newItem("Part","get"); 8 i) V% N: s: d5 m& ~
qryItem.setAttribute("select","item_number,description,cost");
) o0 V& C* M$ XqryItem.setProperty("cost", "100", "gt");
( t5 @' L3 s/ q7 U( l$ t. Q1 r8 ZItem results = qryItem.apply(); ' E$ W. C! t& r5 L$ S% p4 s
int count = results.getItemCount();
- Y8 G6 t# r+ a: w/ p! W& q6 xint i; ! c: B: b" l4 j
string content = "<table>"; ; v3 V5 n3 |# F* Q, t
for (i=0; i<count; ++i) 4 a' N! x; Q U& i
{
. A0 ~( J5 |4 Z) o3 b8 m: V Item item = results.getItemByIndex(i);
4 k8 k6 K4 I( q; z% _# K6 w content += "" + ! t( F! k" d0 H- R: D
"<tr>" +
3 q, T: \& O1 a8 Q7 ?: q" L "<td>" + item.getProperty("item_number") + "</td>" + ) j0 w' H8 G7 Z" H/ B% @
"<td>" + item.getProperty("description") + "</td>" +
1 f, h- D$ i" x1 a" d; v1 n" ^ "<td>" + item.getProperty("cost") + "</td>" + ( }- D M8 p' R8 R: d' x
"</tr>";
. c. `- f- t& w" n) g! N}
0 J8 H1 r* }# a) F; {content += "</table>";
; }2 F; P- p8 d7 c8 [2 lInnovator innovator = this.newInnovator();
" V/ C* y) n; d& s' T7 Breturn innovator.newResult(content);
( I: B, n9 p. G* B5 i D* _2 X
p8 J: X+ m& l' }& p( E2 |VB.Net
+ |$ U+ \( o3 PDim qryItem As Item = Me.NewItem("Part","get")
# o0 O0 w8 g1 j2 d! d- @3 `( e7 EqryItem.SetAttribute("select","item_number,description,cost")
3 k. s" k6 ?9 p' R) k% l+ JqryItem.SetProperty("cost", "100", "gt") ) F- p ^+ H& c3 l
Dim results As Item = qryItem.Apply()
$ r! ^0 @: Y) P3 g6 A) {4 a TDim count As Integer = results.GetItemCount() + g# B; n, v6 k# A: Q
Dim i As Integer : }* F' `2 u: u |8 A: i* l. J5 u3 D
Dim content As String = "<table>" ; K8 r m- u6 R# m) d+ x
For i=0 to count - 1 - h4 o, p' y) p4 X4 c0 l! m- t
Dim item As Item = results.GetItemByIndex(i)
4 m0 a4 |& l$ N$ f! h* ?7 N$ u/ \: V0 D content += "" + _ 7 T, e; s" N7 \: p9 F/ h8 z9 w
"<tr>" + _
8 s7 C% s7 M5 ?9 c# w "<td>" + item.GetProperty("item_number") + "</td>" + _ 7 Z$ ]! B# P9 B/ F1 p; D
"<td>" + item.GetProperty("description") + "</td>" + _
4 N; B* @% J% ~, n# P, d "<td>" + item.GetProperty("cost") + "</td>" + _
7 ~7 R H* ]/ E4 e: |( @ "</tr>" 1 N% ]4 }* X3 u$ H
Next 7 Q @ z5 e( B* a
content += "</table>"
. S, {4 U& l$ b9 l- a& [$ C
% S) h: z' j9 F% y0 BDim innovator As Innovator = Me.NewInnovator()
0 H; \. \8 w* x7 B, E/ vreturn innovator.NewResult(content)
' V' _) L) u2 |
: |- z* F0 N6 M( `# X4 s6 x2 W* i3 G, Q% y
|
|