|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* s5 r) j2 e8 O3 L8 v( T* l
4 ]& `: Y) G) |9 T+ ~2 a% v* T
8 e# j: ^' b7 a) W
+ v. C/ p, ]* F: }, x7 M3 p0 i) W0 ATechnique ' B2 w3 E2 |6 x: U
There is no difference in setting up a query for a single Item or for many. Only the 4 ~+ T+ d6 ?6 R W8 p4 ~
criteria define the set size returned. In this recipe you create an Item and populate
0 s9 k" a. B& s9 z3 r' `the query criteria, apply it, and iterating over the Items returned producing a HTML 3 S' ~0 J u4 z( ] o
<TABLE> fragment. ' F1 q4 a4 b! h1 v% B+ O
/ _. G# \2 `$ ^6 v
8 u( b# V- D; ^. B) }- ~2 J: QJavaScript
' u" [6 a. z7 }8 q t3 G6 tvar qryItem = this.newItem("Part","get"); + `9 ^# V2 [+ C6 p/ i$ T
qryItem.setAttribute("select","item_number,description,cost");
& [8 b7 Y; \" v" M z9 ?qryItem.setProperty("cost", "100", "gt"); 1 m6 A5 C( H# ]) b3 p
var results = qryItem.apply();
, @6 R+ C# x5 jvar count = results.getItemCount(); ) A5 }. G1 J& ^! B
var content = "<table>";
3 p6 O- ^6 Z9 qfor (var i=0; i<count; ++i) 8 l! o- _( Q2 f# @- D; c
{
# E7 E) ?: L, ?6 J" A5 d! { var item = results.getItemByIndex(i);
+ U% O* e1 O5 I+ a content += "" +
# g! q- M: Q; H: W! {; m "<tr>" + : { q! b7 J' M6 {7 [( o6 N
"<td>" + item.getProperty("item_number") + "</td>" +
0 ]5 E7 t2 ^) [& k. v "<td>" + item.getProperty("description") + "</td>" +
1 Y9 X7 R% V* O' x "<td>" + item.getProperty("cost") + "</td>" + 0 Y: X! W! k* s$ S/ ~6 s7 Z; t
"</tr>"; 2 E g0 H" u& f
}
- o; g3 M. Y* Ccontent += "</table>"; + w8 ]+ j; j& W
return content; 9 |4 X3 D+ j4 n$ v; C, Q
- w; T4 I) ?3 w" z$ s
C#
q. [( v' o; x8 n; B' iItem qryItem = this.newItem("Part","get"); - [! o/ q) S. G3 e
qryItem.setAttribute("select","item_number,description,cost");
/ ~( A! q+ k. U2 k5 s. _. ?, ?qryItem.setProperty("cost", "100", "gt"); , k9 a8 K% w X$ C' a1 X
Item results = qryItem.apply(); * @3 J2 f3 y# V! Y. }
int count = results.getItemCount(); / H: q& \) Z+ f( |9 c) z/ K
int i; % _- t4 T3 w } {; H3 w
string content = "<table>"; $ m; w3 _3 [$ ^! |8 A
for (i=0; i<count; ++i)
, s) P5 @! n* E7 H& s- q{ ( s0 Q# s$ @* F2 Y* P
Item item = results.getItemByIndex(i);
; L( K, p& a. r+ o% P" [5 e e" O content += "" +
4 Q) B4 k7 l$ |' T+ [ "<tr>" + - D) {' Q( K, h% f
"<td>" + item.getProperty("item_number") + "</td>" +
; w7 l5 x- J3 Y$ c8 Y7 H3 } "<td>" + item.getProperty("description") + "</td>" +
! K1 A: [: i8 X8 H" }, @ h8 T7 `' | "<td>" + item.getProperty("cost") + "</td>" + , u+ y3 G6 k, Y+ l" y1 ~
"</tr>"; 2 h- t- r# P1 T$ m$ k* g+ f
}
& R, p4 Q5 M9 S) l0 |0 Q' x+ V, Icontent += "</table>";
" E1 n* i4 f$ B! Z# BInnovator innovator = this.newInnovator();
$ g( `, l" e) Y- ~4 O# }4 qreturn innovator.newResult(content); + u0 e4 X1 P" t4 n
/ r2 U* S$ ~ D( n) qVB.Net
0 e* z0 d& \6 P+ Y4 Z/ tDim qryItem As Item = Me.NewItem("Part","get")
- \( ^% o- W/ nqryItem.SetAttribute("select","item_number,description,cost")
) {. M. q# T0 `, ~" m+ x" p/ UqryItem.SetProperty("cost", "100", "gt") 4 Z- z! A: Z$ ~! V: G
Dim results As Item = qryItem.Apply() ) K9 C$ M7 X& B; j9 I1 E
Dim count As Integer = results.GetItemCount() ! d' a: k, q7 e8 [) r; k
Dim i As Integer 9 S# S! C* U) A1 h9 Z
Dim content As String = "<table>"
g1 a# _. H& a, d1 b3 rFor i=0 to count - 1 % k1 y) J4 B. V
Dim item As Item = results.GetItemByIndex(i) 3 }5 A# h5 C5 d" w+ ^- V" `
content += "" + _ % A; g$ |6 e1 h+ d
"<tr>" + _ * O- x! e9 h* O5 q) l3 D
"<td>" + item.GetProperty("item_number") + "</td>" + _
3 N& p" x4 V. p "<td>" + item.GetProperty("description") + "</td>" + _ 8 ] @1 f7 G$ }4 \9 l" d1 z+ C) g: {
"<td>" + item.GetProperty("cost") + "</td>" + _ 3 K4 w# q: Z, y) b( `/ S/ G/ r
"</tr>"
k, Y/ H: i9 g: zNext
( C. t3 j" ~6 x+ l/ U0 U: Ccontent += "</table>"
3 F- r5 O& `7 w5 q" k& Y
6 m8 H C' V$ s1 J& N8 Q" F% PDim innovator As Innovator = Me.NewInnovator() 0 W$ _" G4 k; q# h! m2 d2 x
return innovator.NewResult(content)
& H" p7 u4 v3 Y( L3 n5 e5 U* q$ @; P. L {$ @& F+ w
2 d1 j1 |( ]" f, A% m
|
|