|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
" s7 U! x& S3 D/ R
; ]0 W$ `1 f: Y6 u/ q( t) t
8 H4 v- Q0 H5 }' \+ r- Q9 j) D5 \0 o+ M1 K3 i( d
Technique
0 N; e( H: `% T) Q1 [9 I/ s; F1 BThere is no difference in setting up a query for a single Item or for many. Only the
2 m8 d6 X3 V8 Y; R0 q$ Dcriteria define the set size returned. In this recipe you create an Item and populate
: P' `& {1 j& y. o; k+ D) Y0 mthe query criteria, apply it, and iterating over the Items returned producing a HTML / h. Z. |* B* U- f6 d# e8 m
<TABLE> fragment.
/ \! ]2 ~6 H7 Q1 W) Z- l
- ~" I, I: @& G0 n4 P% S1 b& D$ a. }( K; b" ]
JavaScript : m; f' n8 _1 ~
var qryItem = this.newItem("Part","get");
+ @! M; q. A3 C' N5 H. q) BqryItem.setAttribute("select","item_number,description,cost"); & |4 O7 E% V3 Q- u! _ X: \
qryItem.setProperty("cost", "100", "gt"); * z p' T# p# U
var results = qryItem.apply(); 4 e! F/ c/ q3 c; [2 Q
var count = results.getItemCount(); + x) `0 O8 u8 l
var content = "<table>";
$ v( K$ a% g4 }/ Xfor (var i=0; i<count; ++i) G3 D3 H8 F0 v% _7 S) ^
{ % o& h5 k4 j& w$ E! Z9 O
var item = results.getItemByIndex(i); ~: H8 v4 j0 B' a
content += "" + + A# A" w, K! o0 ^ |$ h
"<tr>" + 1 b* c% O( q9 P; N' R! @
"<td>" + item.getProperty("item_number") + "</td>" + , Q2 _5 o# x. V3 {3 [' x2 ^
"<td>" + item.getProperty("description") + "</td>" + 0 {. e! p$ ^7 v
"<td>" + item.getProperty("cost") + "</td>" + ) k' m: |% c7 R: P) j# w( g4 p4 j
"</tr>"; ) ~5 n" D( c- h5 h6 |
}
! w5 K' D# F9 Lcontent += "</table>";
! J- s: k( D, e+ hreturn content;
& v4 b: x' q- ?1 ~ 1 \- u( Y! L( A3 B
C#
) G$ ]3 |5 S, Z; c0 |( iItem qryItem = this.newItem("Part","get");
7 N1 n7 R% Y0 f" p; VqryItem.setAttribute("select","item_number,description,cost"); # W! y/ U, s6 F @' T
qryItem.setProperty("cost", "100", "gt"); 3 ~7 [2 Q- _7 u3 u
Item results = qryItem.apply();
' K3 Q0 E6 I; qint count = results.getItemCount();
+ M+ B: x2 @1 k! z0 M( {& ^0 a& g/ J, Xint i;
4 u g p3 f Dstring content = "<table>"; 6 P+ Y3 I7 G: C9 U% H
for (i=0; i<count; ++i) + h, |3 w# p' \4 D; ]1 h; E9 ~
{
. }' F( N' E1 V" g- a% @% K0 d2 `9 V/ ` Item item = results.getItemByIndex(i);
$ x7 ?" K9 r& v9 k* ~" y content += "" +
! m& r$ h2 w5 X! T' ]9 t; L; Z8 d "<tr>" + i( t& p# z; T( j! i: S G- y
"<td>" + item.getProperty("item_number") + "</td>" +
) D% U, W4 p# j7 D4 x: Z- v) t, _ "<td>" + item.getProperty("description") + "</td>" +
+ d2 ~7 x% n4 F "<td>" + item.getProperty("cost") + "</td>" + / `0 q9 Z5 _6 D. ?
"</tr>";
& g* E2 y! X7 d}
5 z# l# x: F$ Tcontent += "</table>"; : [, a1 N) B4 J1 T% { l
Innovator innovator = this.newInnovator(); ) }4 \- h" S3 ?0 M; v
return innovator.newResult(content); 5 V. v& [( t; N" X
/ W6 d9 e9 R4 c! TVB.Net 9 T* w8 I& c; ?
Dim qryItem As Item = Me.NewItem("Part","get") ! ?) g9 F4 _4 d# K
qryItem.SetAttribute("select","item_number,description,cost") " R1 C) m: C; P' R
qryItem.SetProperty("cost", "100", "gt")
$ Y3 W/ l# x# ZDim results As Item = qryItem.Apply()
, L5 q5 N4 ^4 L/ }3 H3 g- @Dim count As Integer = results.GetItemCount() 1 E' g& W) }* h) Y3 t8 y
Dim i As Integer J: ]. K: b$ [7 U4 M; x
Dim content As String = "<table>"
# ~: N' I/ h* T1 r0 R2 wFor i=0 to count - 1 4 d9 k5 O9 E) X) G6 Z
Dim item As Item = results.GetItemByIndex(i) * g7 T# O& r2 h
content += "" + _
& }! o4 k$ _6 O G9 W* I. Z- o "<tr>" + _ , u$ h' E3 }0 o7 a2 j- S( ^ c$ H- @
"<td>" + item.GetProperty("item_number") + "</td>" + _ , C4 E/ e9 q9 v- R
"<td>" + item.GetProperty("description") + "</td>" + _ $ a1 K3 w2 L7 X+ G
"<td>" + item.GetProperty("cost") + "</td>" + _
. V( z5 t9 {% J$ x1 N7 s L "</tr>"
5 m: J( ^( e% ?0 b7 _- i1 T$ tNext / j* H' E7 }; l. g4 D0 Q
content += "</table>" ) q/ g8 ?; c2 D: M! q
' J+ [5 D1 K$ N9 J7 T5 n
Dim innovator As Innovator = Me.NewInnovator() ) t' ~: E( K/ w! J7 Y
return innovator.NewResult(content)
; R; I" z/ Y) e* @( k8 _- J! A( L1 o8 h' Z# J- Q; ~6 o
# ]- D! u T5 z |
|