|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% s0 v/ g, S5 V1 j0 i8 F3 K3 c& G& X/ n
) B8 L% O& c7 @/ g/ n5 }4 v( c5 t7 p6 W5 d j
' w3 d' y: ]9 a0 k9 d3 _0 ?" \/ ~Technique
3 T& G3 @0 P, X/ mThere is no difference in setting up a query for a single Item or for many. Only the
& R0 P( A" B" V9 U1 X! F3 D) k Dcriteria define the set size returned. In this recipe you create an Item and populate , A$ W; S( `0 E
the query criteria, apply it, and iterating over the Items returned producing a HTML 6 [6 O$ Q S9 a T1 I; y
<TABLE> fragment. ; c7 d( j% ?6 @3 h
. g7 |/ P, {6 f( S% |! W! _" f
0 y( {: J8 B QJavaScript , @$ w$ a9 B4 [, ]4 c8 x
var qryItem = this.newItem("Part","get"); 0 Y* E* ^* j5 ~( a
qryItem.setAttribute("select","item_number,description,cost"); 0 ?6 r' a% c( S7 _
qryItem.setProperty("cost", "100", "gt");
$ \! G. g; M2 ?0 }' kvar results = qryItem.apply(); 0 ~0 U+ N" v6 A- j
var count = results.getItemCount(); : g Z; s) b: D u& W3 g
var content = "<table>"; . e4 ?: K0 A. O# c# g% ~
for (var i=0; i<count; ++i)
% k6 T4 u. |6 ~! Y{
6 a' G5 V( v0 `7 h var item = results.getItemByIndex(i);
L3 p4 a& B& m3 I content += "" +
# b/ _. ~: @5 \, Z3 X" H; {9 P0 ? "<tr>" + 0 d& O! m( V2 h4 P, Q/ [; y
"<td>" + item.getProperty("item_number") + "</td>" +
7 H7 i' q) ?; P m2 b "<td>" + item.getProperty("description") + "</td>" +
- b+ I7 K3 {5 w# P" W/ z "<td>" + item.getProperty("cost") + "</td>" +
4 f2 @9 e0 q( V: E "</tr>";
6 v: _/ R: f0 I}
$ F2 w. ^" b- m+ Scontent += "</table>"; : \" d2 x& Q+ ]: H
return content; ; v! s0 B! V, z
- n6 B# P# P( @
C#
! Y8 ` ~( i' j) }2 f$ N9 w, QItem qryItem = this.newItem("Part","get");
$ X3 `+ K+ S$ p' w6 M Z$ Q$ tqryItem.setAttribute("select","item_number,description,cost");
! L- x0 v: g. [' SqryItem.setProperty("cost", "100", "gt"); 6 m8 z7 Q0 l! R, {9 ?( Y# i
Item results = qryItem.apply();
: K" a v3 x/ D! |2 s0 Aint count = results.getItemCount(); 3 t. {! n B9 m
int i;
. R& n6 t- A9 {* I& e! Fstring content = "<table>";
% V" c% V0 W2 V$ b$ {9 {for (i=0; i<count; ++i) 1 f" N& }( c# I0 C
{
' Z7 p- j- L: W$ q5 b$ A- x Item item = results.getItemByIndex(i);
' c* h; S3 k1 Y1 R0 L' `# e content += "" + # c2 Z! H Y/ o0 E4 R
"<tr>" +
# p: Q& O1 p4 G "<td>" + item.getProperty("item_number") + "</td>" + % O2 Q0 r1 y3 U; S( n- u' {
"<td>" + item.getProperty("description") + "</td>" +
, c4 p' S% m$ b" M) r3 v "<td>" + item.getProperty("cost") + "</td>" + 4 Q: W' a+ R" y8 h5 \4 ]7 Q* H0 f
"</tr>"; ' c/ c6 }; z" N3 y. }' \/ Z
} " c: u& }- Y) I- U
content += "</table>";
; Z! n U5 R# i# W+ [, @* TInnovator innovator = this.newInnovator();
( }. n( O% }6 g+ V! n/ Nreturn innovator.newResult(content); / m4 l) S- X5 p0 I7 K
7 n, m& W* b8 t. E; d5 _
VB.Net 1 @. W1 C1 T8 w$ F+ U4 P
Dim qryItem As Item = Me.NewItem("Part","get")
8 V3 F) O$ E9 ?% y9 D$ y1 TqryItem.SetAttribute("select","item_number,description,cost")
' A9 E- x# S) p& `* OqryItem.SetProperty("cost", "100", "gt")
" F' k4 s" N- R2 [Dim results As Item = qryItem.Apply() # a& D/ p% [2 E+ t7 P: |
Dim count As Integer = results.GetItemCount() + t' Y4 g2 V, p, O- t6 ^8 T% x( S' p
Dim i As Integer * y8 F; \2 n/ G9 p! m+ l; f- Y& h
Dim content As String = "<table>"
' C/ g) l7 @7 yFor i=0 to count - 1 ) R9 w! {/ v6 I$ k
Dim item As Item = results.GetItemByIndex(i)
; x9 j, n) U# U P" s& S9 \ content += "" + _ 6 w5 E& j/ j1 f4 U7 q' {! ~) j# |
"<tr>" + _
% T& [3 l, R" f5 L "<td>" + item.GetProperty("item_number") + "</td>" + _
( p4 A! a! S' d7 J "<td>" + item.GetProperty("description") + "</td>" + _
) L: p5 _! H6 s8 n "<td>" + item.GetProperty("cost") + "</td>" + _
; N1 l( f" \) N# t$ H* F2 }0 t "</tr>"
! Q/ `! T6 Q$ [Next + Q! X% L$ f: s1 I
content += "</table>"
$ o) C& Q. j# V5 H4 Y$ t& s8 D . D& U* V- G* |) j; h/ |0 I
Dim innovator As Innovator = Me.NewInnovator()
) B5 h" G/ @/ d4 }return innovator.NewResult(content)
& [; t X6 y: ^# ?0 j, V0 a
J' v# u+ u2 H# N7 y' a$ N; r, D! s" X& R& u z. A( v- Q
|
|