|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! M8 z ?$ u* v! d
+ h _3 B% ~3 `9 D* E
/ A( v0 d0 w* \' d) C. s7 j
3 a* _5 t% j+ R! d4 y ~$ {6 Z* tTechnique
2 ?! }# _3 G3 z3 pThere is no difference in setting up a query for a single Item or for many. Only the
0 K+ w! Z1 X: j( N" |criteria define the set size returned. In this recipe you create an Item and populate
2 }+ L5 ?1 {6 f {the query criteria, apply it, and iterating over the Items returned producing a HTML / b, w1 }( r5 d9 F
<TABLE> fragment. ) `8 t- [ ~+ |6 s
; V4 |& i" C4 ^; z
# s' I! P+ O% \. B/ w) u& xJavaScript 1 ~0 q1 L! l& P
var qryItem = this.newItem("Part","get");
4 n. m( g8 ^5 }8 T1 kqryItem.setAttribute("select","item_number,description,cost");
5 J2 p7 K5 i' T) n/ L C7 U' r$ W) xqryItem.setProperty("cost", "100", "gt");
5 l& `( I7 M) n5 F& yvar results = qryItem.apply();
: p P/ F3 ^ ]4 t8 ^, m0 hvar count = results.getItemCount();
9 S# j& P ^0 ?' evar content = "<table>";
. c: }1 Q9 ]; m9 A% T- Q" S4 ^* J- D6 pfor (var i=0; i<count; ++i) 5 Q/ g; c2 I9 D2 Z$ h8 O' {
{
7 O1 n+ m) o5 b' l' ?# b var item = results.getItemByIndex(i); , ], f3 J9 Y7 y9 }
content += "" + - ?4 ^% H/ s/ Z' h& s" z6 a' c8 n& }
"<tr>" +
6 e+ I& g3 U' `3 B. }+ o; h1 w6 w } "<td>" + item.getProperty("item_number") + "</td>" +
8 L- W7 O0 s: p. z# c# l5 _1 Z/ I "<td>" + item.getProperty("description") + "</td>" + " r& n9 s/ g+ R* H/ T3 x7 Z- Q
"<td>" + item.getProperty("cost") + "</td>" +
8 O9 u0 K% d" a; ^ "</tr>"; 4 j: h3 D; X) v) k
}
# ~; p- |/ H: h" Y0 F& A" icontent += "</table>"; 9 E+ g7 I. ^6 S
return content;
, m3 N8 ?2 ?% g% t8 L0 W/ u9 ^0 u
* b$ Q# s" Z5 ]% C' s5 g9 JC# 0 E- L" D: S( @" G8 ]0 D
Item qryItem = this.newItem("Part","get");
) h8 f$ `7 a/ m/ N) o! s- u% e( z3 CqryItem.setAttribute("select","item_number,description,cost");
8 q5 s; v, i* pqryItem.setProperty("cost", "100", "gt");
( _& \7 i& d, R7 v3 sItem results = qryItem.apply();
0 F3 {" C8 j7 O* E9 K+ mint count = results.getItemCount(); 7 s$ C- @+ R: D4 Z- \' C0 N2 z
int i;
& x$ K' i H+ @1 Q+ V( wstring content = "<table>";
+ N+ S* P- H. Q; n8 x$ h% M7 Rfor (i=0; i<count; ++i)
. ?" m+ W5 \3 `{
- n3 A) Z! X( `0 Q6 H# g8 p Item item = results.getItemByIndex(i);
3 }: ?: f1 {7 H content += "" + ( z. O4 `) M7 ]& X d
"<tr>" + 9 h/ b3 c7 L2 [4 W
"<td>" + item.getProperty("item_number") + "</td>" + 4 T4 \6 K3 {* W5 V7 @; M* f
"<td>" + item.getProperty("description") + "</td>" +
0 Y0 E" c/ {* A+ K$ R2 m3 U* M! T "<td>" + item.getProperty("cost") + "</td>" +
/ n9 a' Y" Q' Q- b | "</tr>"; 0 ^1 Q9 f4 Y( Z" k
}
' u0 _+ h) n) B) Z* I1 kcontent += "</table>"; ( g# H- i& u9 S C! i
Innovator innovator = this.newInnovator();
/ D$ p/ `$ q% M* Nreturn innovator.newResult(content);
p/ b" c/ ?/ Q# F0 v
) c$ N7 m- v) }: q) g; t1 j8 J9 iVB.Net ) k$ f$ a! s( w3 |, }9 C0 {
Dim qryItem As Item = Me.NewItem("Part","get")
% H! `! P: r2 [8 {+ v& F, M. H3 W% UqryItem.SetAttribute("select","item_number,description,cost")
- T: Q3 k4 V& D/ eqryItem.SetProperty("cost", "100", "gt") 2 A) j+ E( W6 g; z; N
Dim results As Item = qryItem.Apply()
3 t1 y4 Z7 S- HDim count As Integer = results.GetItemCount()
2 p9 R# x) i3 g5 C! D, mDim i As Integer L$ Q4 |- Q) d+ g' [9 o0 u! G
Dim content As String = "<table>" * z7 u1 C" p( b6 ]7 A# b
For i=0 to count - 1
$ t7 d: a7 k% m' R, ~" V, D Dim item As Item = results.GetItemByIndex(i)
: o5 T6 ~: ]& r% q7 \ content += "" + _
" @( m2 Y* E/ x( K+ [3 b9 J1 p "<tr>" + _
; D$ Z- `/ h! h f. P( s6 \ "<td>" + item.GetProperty("item_number") + "</td>" + _ ' K1 q) G! p# {. m! [/ a
"<td>" + item.GetProperty("description") + "</td>" + _ 4 J0 N5 K# B) {/ u5 S2 O3 h
"<td>" + item.GetProperty("cost") + "</td>" + _
( {5 J0 l* T+ u3 _+ M0 h$ ] "</tr>" ' J1 B9 D: e c( [+ ~! c* J5 `
Next
5 B* M/ r+ J& Z- J$ e# e3 }content += "</table>" 6 t5 f( C# d# [: m
& g/ |5 `8 c# R
Dim innovator As Innovator = Me.NewInnovator()
! v! E l+ o P, h( a4 ireturn innovator.NewResult(content)
' X- T" g" y3 R1 w
9 J& O8 q; C$ E' T) K% O9 I
" R9 H+ a9 |& o; e, [1 _ |
|