|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# ~# K* ]) A2 O% T; R
( Q0 v e* n8 v! D, t8 m4 `
$ D( D5 t# f1 _: l D- y3 V" s* H9 q7 D4 a
Technique
5 X* o# |5 a4 C; D7 d8 Y: ZThere is no difference in setting up a query for a single Item or for many. Only the $ n+ n* H! b0 _4 t. w) M
criteria define the set size returned. In this recipe you create an Item and populate
* ~/ Y+ a6 K3 K2 L$ ^& dthe query criteria, apply it, and iterating over the Items returned producing a HTML
3 N* ?, {$ z: `3 w8 D<TABLE> fragment.
- U% [$ Y: P$ q, x# X$ C9 Q$ e+ Y' e% B1 B2 r* r; \
- g& w5 g. [4 U; p8 F4 n5 r
JavaScript + y" s% `; ~/ [$ Q' `
var qryItem = this.newItem("Part","get");
N: H3 T. X) D. N" t8 r' I. bqryItem.setAttribute("select","item_number,description,cost"); 5 {* W- M6 c6 t6 K
qryItem.setProperty("cost", "100", "gt"); 1 g4 t' W' D) U) y% \; d# e
var results = qryItem.apply();
; q" n" k6 }5 D: o+ W* u% q+ dvar count = results.getItemCount(); + x6 I, A7 ~! o. B; l
var content = "<table>"; & t/ l! J5 G$ n1 r4 ^
for (var i=0; i<count; ++i) / ]/ \ }2 f, O% t. e* _+ h
{ , L4 y. G1 `; I$ c. {
var item = results.getItemByIndex(i); . n- Q1 b0 D, J/ o' A
content += "" + 4 g x$ v: t; K1 A
"<tr>" + & v+ A- Z# e5 r% Y( p8 |1 o3 h& U6 s* v
"<td>" + item.getProperty("item_number") + "</td>" + 3 E. A1 e7 C1 _& r5 a* ^
"<td>" + item.getProperty("description") + "</td>" +
5 q b5 J9 q Y* ` "<td>" + item.getProperty("cost") + "</td>" + 1 L: j: L ~: M7 t$ Q- i$ d
"</tr>"; " e- u' I8 W6 B# {- s* X- t
}
" {3 M7 g3 x- X A5 @: Zcontent += "</table>"; ' D+ g4 F8 Q# |9 I) L. r* M U. y! \+ r
return content;
" f. q' m, G$ X0 G1 _+ g! `0 Y 3 g; W- y$ \/ Y* X, W! |4 N# V
C#
& F6 y0 C, G+ o) I( `" d% yItem qryItem = this.newItem("Part","get"); 0 p) S. r! y9 S8 u& K% i
qryItem.setAttribute("select","item_number,description,cost");
" l! z7 v# @) k4 |; J& FqryItem.setProperty("cost", "100", "gt"); ; V: e4 `* e0 e. H8 [0 a: f5 a4 H
Item results = qryItem.apply();
9 K6 K, B& n) Y* H" b6 C: Tint count = results.getItemCount(); , \2 m$ U8 Z7 ]# \+ x$ Q7 E
int i;
& h& K; t, H- u* c: Fstring content = "<table>";
+ N1 s) M/ w/ ]! n# Yfor (i=0; i<count; ++i) 8 K! z1 Q, R( C9 }8 K! z6 A
{
" X8 ?8 U. v! t& x. s Item item = results.getItemByIndex(i); 3 _+ K1 ~% W i3 w$ e( P
content += "" + ' {& t! O, F; r3 D9 r; H
"<tr>" + - H' U& u8 R- P. Q
"<td>" + item.getProperty("item_number") + "</td>" +
. I8 W& ^+ m. ^ "<td>" + item.getProperty("description") + "</td>" +
$ b3 r0 `: ?; d; A* | "<td>" + item.getProperty("cost") + "</td>" + 2 z: k1 _: v4 M' U6 `" k
"</tr>"; % S: s e7 w$ }- N, g/ m
} + U/ v! H( z4 H$ M8 l" t; k/ E4 V; q
content += "</table>";
- {. Y0 ?% a; G8 X0 l! CInnovator innovator = this.newInnovator(); % i8 H- T# M( K3 F; O3 m4 o
return innovator.newResult(content); " l1 a: H) @' W; m. }1 ^
6 \1 r- ^5 K& c6 g uVB.Net 6 T: J5 \) d% w
Dim qryItem As Item = Me.NewItem("Part","get") - w p: J) D7 d% s4 ]! l6 d7 H
qryItem.SetAttribute("select","item_number,description,cost")
$ k9 ^: E7 W6 d" K6 b# }) wqryItem.SetProperty("cost", "100", "gt")
- P; W+ g7 q' C: K, g$ c QDim results As Item = qryItem.Apply() : X* j! G7 F ^$ w+ @
Dim count As Integer = results.GetItemCount() # \8 E( C. l7 e2 i; b
Dim i As Integer
4 m2 `/ R! X8 m- ?- P. {1 bDim content As String = "<table>"
7 \* ]1 m5 j6 k( u, g9 J5 X0 o4 [For i=0 to count - 1
* B$ V2 H) ]8 K# ]& h6 l Dim item As Item = results.GetItemByIndex(i)
) e% ] C& f% z2 v content += "" + _
/ b0 z$ k M+ L* E' I "<tr>" + _ : E# j5 v. Z9 C7 X1 X2 B" j5 Z
"<td>" + item.GetProperty("item_number") + "</td>" + _
: p1 c* S% M$ D$ \3 H F0 q7 x "<td>" + item.GetProperty("description") + "</td>" + _ 2 t' _+ n3 j) h2 H! ? S
"<td>" + item.GetProperty("cost") + "</td>" + _
Z4 G2 C7 |# ]0 Z$ E "</tr>"
) }6 S& V! Q VNext
8 F4 K" t) B8 X+ ucontent += "</table>" 9 F) Q4 Z+ |( Z4 C# ^& m# a
5 V- {& K" @1 y9 d2 A2 m x- [
Dim innovator As Innovator = Me.NewInnovator() & Z% l, {' ]0 K( p5 g/ e6 M4 Z5 d0 s
return innovator.NewResult(content) 6 j6 j& G0 ~; Y9 Z, Q. _
) P4 V1 @# b1 k: |1 H2 ^
$ J1 t; d/ ^: c* j
|
|