|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ T2 \4 m, \' d) N" P7 F; r$ ^
" ]8 P/ |! X, f) j
3 ~& l+ W3 F. G6 N( ~. @( V7 [# S' N2 X; X, |% D' g" l2 e$ d
Technique # ]( C/ u6 z" `
There is no difference in setting up a query for a single Item or for many. Only the
( N1 _, B6 M% zcriteria define the set size returned. In this recipe you create an Item and populate
# s( [2 a' e0 vthe query criteria, apply it, and iterating over the Items returned producing a HTML / x/ ?8 n2 H; g% e# w( r- k
<TABLE> fragment.
1 A9 ?$ @. `& y# z/ s- X- \$ {
# H4 L+ p1 O6 h7 Q! r9 H2 n5 o9 H1 Q$ z) `- A
JavaScript + v$ z7 R& f8 X+ s
var qryItem = this.newItem("Part","get"); L# v m) |8 P; D6 ]1 q
qryItem.setAttribute("select","item_number,description,cost");
( w& G( F2 c; G# tqryItem.setProperty("cost", "100", "gt"); " n& @9 P0 b j, D2 }* N2 h
var results = qryItem.apply(); % t& Y& f! B% g7 o; a3 ~' R
var count = results.getItemCount(); " i# L. G8 s* f& O( \
var content = "<table>"; * c8 L+ U+ Z( |3 `
for (var i=0; i<count; ++i) 1 R2 _) S8 ]% E; I2 t+ c
{ 2 \3 X4 W( T5 r9 M- ^# N
var item = results.getItemByIndex(i);
, ]4 D2 M' R$ ?1 ]; r. z content += "" + i' d+ H- N' Q6 Y
"<tr>" +
7 u, I: D. `8 _4 W; k: R "<td>" + item.getProperty("item_number") + "</td>" +
% h5 h( m9 C% S k' z "<td>" + item.getProperty("description") + "</td>" +
5 }- d& |4 R" j- N4 H$ i/ h "<td>" + item.getProperty("cost") + "</td>" +
" c4 j2 K( g" d; Z "</tr>"; ; |$ E! i6 c+ Z4 _4 b
} ) c8 }% q* M# J" S- s! X' a6 J
content += "</table>";
) A4 t0 Q c1 o' |return content;
: R5 A+ A3 b7 K' L9 k5 x* T2 ?+ v
( N% X# J# T0 m d) y1 v+ u+ r# NC#
5 l: d/ d% S0 m0 x- {, bItem qryItem = this.newItem("Part","get");
. r, ~. n- K+ X6 m9 Y3 R1 e cqryItem.setAttribute("select","item_number,description,cost"); 2 ^5 y. {. F* }2 c. T! Z: o
qryItem.setProperty("cost", "100", "gt");
/ I1 @. o9 J1 M( dItem results = qryItem.apply();
. z: x; I! M* r* C' K0 |) \int count = results.getItemCount(); & r; X! ?6 p6 n# K3 Q+ w( {
int i; & J3 f, L k& s! o$ v& w
string content = "<table>";
) }& h& {& I" r3 U. vfor (i=0; i<count; ++i)
6 f9 ~7 Q+ m0 \/ y9 j9 [{ + T2 N; A9 Q' i# I
Item item = results.getItemByIndex(i);
( J% r' T" p/ U5 s5 Z' t1 ` content += "" + - G6 U4 n8 f( @; ]- }+ f$ n
"<tr>" +
7 q5 d. N: f6 N# S# ` "<td>" + item.getProperty("item_number") + "</td>" +
- f& _" ^' G S "<td>" + item.getProperty("description") + "</td>" + ?: Z) g' ~+ ^. |* X0 N
"<td>" + item.getProperty("cost") + "</td>" + 4 r: T, I! |# F2 U" P) w# x
"</tr>"; ( S0 ~% p) Z- _4 N, c' Y# N
} 9 O4 R3 I& N' S+ x4 t/ {* {
content += "</table>";
6 [9 E# ?( ?* Z/ J5 o; Y; QInnovator innovator = this.newInnovator();
/ R X; d; }6 D: rreturn innovator.newResult(content);
, C1 r- L9 H8 N) O
& j. A6 w: v: x2 U/ ?- h. kVB.Net
7 d9 E; C. A& D* zDim qryItem As Item = Me.NewItem("Part","get") ! `7 ?# X) F; V# A
qryItem.SetAttribute("select","item_number,description,cost")
& m2 a* u% e- a5 S _qryItem.SetProperty("cost", "100", "gt")
; S0 A1 @& x- D/ j- |Dim results As Item = qryItem.Apply() + j+ e, R1 D+ c# W
Dim count As Integer = results.GetItemCount()
2 |5 c, T' e8 n/ `" c DDim i As Integer P; ]" P7 N% T ]# z6 ^% B7 q
Dim content As String = "<table>"
% u1 g+ T; O+ S. S# ~* I/ NFor i=0 to count - 1
4 m7 @. ` m$ V, ~ Dim item As Item = results.GetItemByIndex(i)
, n2 ~) B5 _2 p' O/ H6 O P content += "" + _ : @. C$ I9 d- ?$ q1 O
"<tr>" + _
z+ w! s1 f$ z& X: D! Z "<td>" + item.GetProperty("item_number") + "</td>" + _
0 ^- p' V2 X* j4 `7 w2 Y1 l; M "<td>" + item.GetProperty("description") + "</td>" + _
' {" K. W" G4 L% u# | "<td>" + item.GetProperty("cost") + "</td>" + _ 7 V. ?. O- O+ S4 Q8 w& B
"</tr>" 0 S' }" p5 L* q4 ]0 t& H3 m8 S
Next
6 W/ \$ u2 o8 P; i" U/ [content += "</table>"
; M. c1 O7 w$ j" l/ ? " P- Z/ _5 F2 \" ]) Q
Dim innovator As Innovator = Me.NewInnovator() ( \$ Y4 b) J& S- X/ B( v7 w6 }
return innovator.NewResult(content)
3 R, c. C3 T: |! M" P9 y1 [; Z4 Y& `7 N( e& S
) J4 ^! T& q- C. M/ {6 _& c# Z |
|