|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 p& G# }7 J3 O' h. o+ L9 ~
. M+ B8 ?/ y$ {, v6 L9 l- f/ y- d" Q- P+ s( `$ t/ H& z
9 x9 F8 l; M+ h( L1 Z
Technique 3 H5 E3 [, w7 y* H. g; {
There is no difference in setting up a query for a single Item or for many. Only the 9 r$ C0 }; m$ N h
criteria define the set size returned. In this recipe you create an Item and populate 1 C1 u. O; J( u* V2 P+ p
the query criteria, apply it, and iterating over the Items returned producing a HTML
' D) Z8 D% t* {+ q5 e<TABLE> fragment.
7 V8 \& [5 I( V
1 ?: G6 d, t! p2 n, U( p/ U" L R/ U6 G# }; g0 d
JavaScript $ y9 @3 D6 @: X7 U' S( X$ r+ m
var qryItem = this.newItem("Part","get"); " t# ?7 u) \# s5 E3 P& z
qryItem.setAttribute("select","item_number,description,cost"); 8 Q- e' t0 ]; E9 c9 ^
qryItem.setProperty("cost", "100", "gt");
3 V6 _! j0 t' F1 Q) lvar results = qryItem.apply();
2 d. F7 h7 F5 K: Ivar count = results.getItemCount(); 1 s5 i$ }- j- u% }( K/ C
var content = "<table>"; # P. E- }/ v l6 i% o' V0 m4 ?
for (var i=0; i<count; ++i)
5 E( v8 _1 g |4 t6 |{ " T9 R4 h( C/ l& g0 c
var item = results.getItemByIndex(i);
: V# y% l& D) a0 H0 } content += "" +
7 [* Q- ^3 T0 {' s# K) `& x: Z: R "<tr>" + # g- q* @8 f4 U/ z: z
"<td>" + item.getProperty("item_number") + "</td>" +
2 J/ E3 U) [# ^) N' |! A "<td>" + item.getProperty("description") + "</td>" +
) m6 Z+ B7 d1 ]9 i! i "<td>" + item.getProperty("cost") + "</td>" +
1 `% x% ~+ o. N/ n8 G4 E "</tr>";
% M$ i8 p8 C( G: f, b1 R" e; Z! T} + T' L' T* h7 r: l. T! i- U
content += "</table>";
9 d: \9 z" [- `& R- dreturn content; 4 W; |3 w$ q/ t* j
: C3 s+ } T4 ]; rC#
: Z/ f3 l* a6 LItem qryItem = this.newItem("Part","get");
: N' E+ X" ]3 @- f' R0 {: hqryItem.setAttribute("select","item_number,description,cost");
" m; U4 e, U6 v s6 O: }" ?* @qryItem.setProperty("cost", "100", "gt");
8 E, I* v( K) d* |, d2 MItem results = qryItem.apply(); 4 ?6 r$ f+ {) `; G
int count = results.getItemCount(); # ?+ Y. ~- k8 r8 ^1 r* H
int i; 7 Y7 L4 E; x/ k* p
string content = "<table>"; 8 U, Q' t' G. b4 Q
for (i=0; i<count; ++i)
: O+ k- l ]) z* V{ ' h5 F/ m* o% o7 s
Item item = results.getItemByIndex(i);
) b1 l$ b0 n" C5 `* C8 W5 N5 W content += "" + # g2 s6 K0 H$ `1 y" J# \
"<tr>" +
! U6 y. ]3 O+ Z; ~4 ]' } "<td>" + item.getProperty("item_number") + "</td>" +
: {- ]+ k9 b" } "<td>" + item.getProperty("description") + "</td>" +
. ^6 i4 Z W9 K W: r "<td>" + item.getProperty("cost") + "</td>" +
4 ?2 [! S2 s( e "</tr>"; % }% |, m+ N5 j; J3 Q
} % M" x" P: p; j+ f/ i6 ?# H
content += "</table>";
: R% O4 N, f. B: O8 ~' v1 M: |3 FInnovator innovator = this.newInnovator(); 1 |( u$ H3 m4 i( n
return innovator.newResult(content);
+ W, p, r' K( X3 |0 V- Q1 m6 h
7 P/ |& {0 \$ O: ]VB.Net
4 { R& b! }# X9 G! a: UDim qryItem As Item = Me.NewItem("Part","get") 3 ^& T8 s8 N9 U3 y' o/ k
qryItem.SetAttribute("select","item_number,description,cost")
?$ b! W0 `# `. lqryItem.SetProperty("cost", "100", "gt") & W w: F' L9 }" C
Dim results As Item = qryItem.Apply() 8 S( B0 I. h6 v% F$ K; ]
Dim count As Integer = results.GetItemCount() 2 ?% G* S: @5 e3 G( `9 V+ j
Dim i As Integer
* t [+ _* K2 g3 Z K0 mDim content As String = "<table>"
- e, N0 F: S- J; tFor i=0 to count - 1
1 M! n* ^( [, n' F& {9 \8 {1 Y2 H. n Dim item As Item = results.GetItemByIndex(i) 6 ~5 E( M T" P( Z; \' G, f* R* }- Y
content += "" + _
0 ~6 e% M$ [" |! ~& C "<tr>" + _ - g( Y: Y. s5 O( d: G- H
"<td>" + item.GetProperty("item_number") + "</td>" + _
f6 j+ q4 `0 c ]; w0 L! L" F; ^# W "<td>" + item.GetProperty("description") + "</td>" + _
& Z$ E6 f- X& H+ y! l4 r5 g5 j "<td>" + item.GetProperty("cost") + "</td>" + _
0 m, b; J: n' y, N& C' g$ K0 X "</tr>" 0 F1 T! @1 O, {, i9 o+ K
Next
0 S/ @3 v- _9 B( i1 _7 `content += "</table>"
5 E! Q. K8 ?; P9 f1 y: b
" p2 u B& P8 m' NDim innovator As Innovator = Me.NewInnovator()
2 B/ e8 T& K, nreturn innovator.NewResult(content)
4 `. m" L5 Z( ^, f
% \; W ~5 M( M- L+ V) g, s& s" ?' ^0 X- [% b9 \
|
|