|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, ~/ T) A; ^; _% u+ ?5 `
& {/ c1 n1 Y( i. |. |+ t. R1 R S8 r/ ?0 X: O% L
: c, b" G c2 W7 x0 _, ^2 DTechnique
& F7 G2 {+ d3 B7 f h2 U: |There is no difference in setting up a query for a single Item or for many. Only the
/ w9 R) ^- m ~" Qcriteria define the set size returned. In this recipe you create an Item and populate
3 T/ I" |0 V, z& mthe query criteria, apply it, and iterating over the Items returned producing a HTML
( ?% F( I/ m3 w) V. ?% e+ I/ k<TABLE> fragment. * W) Q5 K- ]1 t
7 n& t( n. D( G
( x& P- c) x' k( `! _
JavaScript * V A* z6 g5 y4 r# E" \
var qryItem = this.newItem("Part","get"); ! g- J8 D5 C Z* @( F! I5 u. @% ^
qryItem.setAttribute("select","item_number,description,cost"); 0 M2 C; @- j9 ~5 f4 r
qryItem.setProperty("cost", "100", "gt");
: }+ W" J( C: { r- Y6 {9 Svar results = qryItem.apply();
' i/ {+ @+ C( G7 u. k+ P0 w# R) K9 Wvar count = results.getItemCount();
0 m7 }( K/ U- }+ {) T* F0 t, ?) Cvar content = "<table>";
: T; }1 z3 s" }# _9 ^: E- nfor (var i=0; i<count; ++i) / P' w3 J4 N, U
{ 1 V* b! F! _8 c4 m" I. e& s# q: @
var item = results.getItemByIndex(i); : F& B3 @7 e' y
content += "" + % }; E+ x2 `; H" Y$ B9 z8 `! u
"<tr>" +
* W1 v( ^& { x9 [9 {' ]. J, | "<td>" + item.getProperty("item_number") + "</td>" + # I" F% V2 l; w4 q0 |( B
"<td>" + item.getProperty("description") + "</td>" +
& ]' {! j% o) f2 M9 w& W* z "<td>" + item.getProperty("cost") + "</td>" + + R) d* l3 Z4 u- z8 q
"</tr>";
# C% b6 z3 C b# J+ i}
. q7 N4 X; m9 scontent += "</table>";
! {- U X1 ^5 P& x5 zreturn content;
% i: ~6 Q4 s/ ?* ? : a) c [# f- F6 Z `, j+ y
C# 3 ?- \; { o1 X9 ^ o7 g
Item qryItem = this.newItem("Part","get"); 6 N/ m4 l) U+ V- }
qryItem.setAttribute("select","item_number,description,cost"); ( P4 w" e" B% _- ]% D/ D
qryItem.setProperty("cost", "100", "gt"); : C/ h U2 o7 C6 u- F8 r4 D! Z
Item results = qryItem.apply();
, L: j" W. M& q3 d- j; ]0 \int count = results.getItemCount(); 0 C. c0 s/ V" r- b( }& Z4 _
int i; 2 ]* t Q0 y- l3 X: Q6 f2 \
string content = "<table>"; 8 U$ }4 S- b2 ]# B+ G$ f; |
for (i=0; i<count; ++i)
; J9 b5 k6 s+ B4 g/ e: n9 ~{
/ n& f' x5 v, h* B5 K9 ^7 m7 Z: X/ C: e Item item = results.getItemByIndex(i);
- P- C. [" Q" P, V content += "" +
7 j' V4 j% ?- K& J& w( M7 i0 @$ Q "<tr>" + J& K5 ?8 S) k. n4 p4 a) {5 `
"<td>" + item.getProperty("item_number") + "</td>" +
6 [- T# U& |6 L "<td>" + item.getProperty("description") + "</td>" + # u# t Z. P. X3 l9 R! U; B
"<td>" + item.getProperty("cost") + "</td>" + ' K2 P. u# Q* C- p$ G4 t. G6 @8 [
"</tr>"; 3 t# j. a; ~, s& K( F4 D( ]
}
G: Z8 d; E2 }5 b, h& V( ccontent += "</table>";
& m m8 ?* E5 [3 x! b9 vInnovator innovator = this.newInnovator(); 7 |4 k$ F6 m; D# g5 v" u
return innovator.newResult(content); ) P; m( ~. T5 r' j
9 F5 h/ o( E7 m) n+ T7 s
VB.Net
& I: T# ?6 [! x" TDim qryItem As Item = Me.NewItem("Part","get")
; X: Q% I! Y; t$ P$ uqryItem.SetAttribute("select","item_number,description,cost")
+ c2 F1 ?( }$ T/ F4 P& }qryItem.SetProperty("cost", "100", "gt")
/ N0 D$ {7 D4 {* o1 sDim results As Item = qryItem.Apply() . S+ U* f( H' @2 B. v
Dim count As Integer = results.GetItemCount()
. ?8 S+ @. N! gDim i As Integer * J, g5 L6 [% ]& l6 e- s6 }
Dim content As String = "<table>"
8 d3 I/ u" h$ H+ n) ]For i=0 to count - 1
0 O4 x3 T7 S- C! C+ u$ o* K Dim item As Item = results.GetItemByIndex(i) 4 G% s4 f4 q/ {# [' H
content += "" + _
+ g. A. M! U. P5 l! c/ D1 a* N "<tr>" + _ , I% m( [/ ?2 o5 ^5 b! a! E. l! n
"<td>" + item.GetProperty("item_number") + "</td>" + _ 6 V$ h$ X7 n4 t' ?' k% S- o
"<td>" + item.GetProperty("description") + "</td>" + _ . k% n2 J# U: A6 l \% ]
"<td>" + item.GetProperty("cost") + "</td>" + _ + ^" X9 j/ O5 {
"</tr>" ' R* P7 b+ X6 K& r% N5 @. T
Next $ G5 }* y& z/ B n. k: }
content += "</table>"
+ t8 ~1 g- n9 |6 f1 P 1 P* o3 C) M' k8 m) A; U5 a
Dim innovator As Innovator = Me.NewInnovator()
0 t; r8 W0 X. ?1 g2 L) W( Lreturn innovator.NewResult(content) . _) u, L, A* f, ^4 o1 c' L6 ~6 l
! x1 C+ E) f- g) a/ ?# n" g% u3 D& A9 ~$ g5 R5 ? F
|
|