|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* Y# U4 u' q- q/ `5 K, `8 V9 @6 k3 q$ X4 X' `0 g$ b
1 H3 V* t5 H4 P" `" ?
8 l( Y/ Q) d" cTechnique
* S* l/ v; [; h4 SThere is no difference in setting up a query for a single Item or for many. Only the
/ Q+ \9 {8 l4 f x' t, e, Jcriteria define the set size returned. In this recipe you create an Item and populate 0 m5 ]6 [$ ~7 D% z0 T, { _2 I
the query criteria, apply it, and iterating over the Items returned producing a HTML
, J1 y: X, v: o$ g<TABLE> fragment. |8 l% u+ L7 O# R
8 d8 ]; ~8 P' m$ w0 ~3 H
/ F1 c8 K6 k \* E/ @: nJavaScript
! W) I# }$ H, \var qryItem = this.newItem("Part","get");
; O! P h' R, O# WqryItem.setAttribute("select","item_number,description,cost"); 3 D% F0 B1 d% h" w$ u' o
qryItem.setProperty("cost", "100", "gt"); ' O- @6 B* [& G; V$ Y
var results = qryItem.apply();
. O0 M% C' Q D0 B% W5 K7 Qvar count = results.getItemCount(); f U- R1 q) [8 Z# |
var content = "<table>";
3 w7 ~; F( E# `4 _1 _' Zfor (var i=0; i<count; ++i) 2 ^8 a6 r* |! A7 ?) B9 n0 g* `9 `
{ 8 F2 a( g6 k) M' I S+ C- s
var item = results.getItemByIndex(i); 6 U& W, n! ?% N I6 s+ B2 l
content += "" +
+ c# F- q' ? n- n" K4 L/ r1 g. q "<tr>" +
. A6 a4 x9 G# L+ {& g- o "<td>" + item.getProperty("item_number") + "</td>" +
7 f& _" o' V6 }( a9 J5 T. Q% X "<td>" + item.getProperty("description") + "</td>" +
9 Z$ s# O; o$ ?, n1 D "<td>" + item.getProperty("cost") + "</td>" +
, D- K8 K# i2 q/ L% t/ k# Q J "</tr>"; 4 G- y+ {% h2 O
}
, `" m5 @; E* R6 w# \content += "</table>";
0 C0 A0 _4 h" Q; r4 R9 U6 n- J/ Yreturn content;
+ j* K; ^. g2 w! q& ?
7 M; p2 |: f$ _1 s0 V/ P. ]C#
3 p+ o f" C# a* }& UItem qryItem = this.newItem("Part","get"); - ^/ P" W' b Z2 K
qryItem.setAttribute("select","item_number,description,cost");
- h; `9 T Z! R4 b8 ^3 l1 AqryItem.setProperty("cost", "100", "gt");
+ s# H- A2 t& V( [# @Item results = qryItem.apply(); 9 K3 u. k4 m# l; c
int count = results.getItemCount(); 1 o) M5 R& Q+ g/ Q6 Q" M
int i;
# ^4 H6 s. Z: A4 z Lstring content = "<table>"; 2 d3 W6 ?5 t2 f3 }
for (i=0; i<count; ++i)
6 b; ^6 d, ~ @/ I* [! J{ 3 H/ v$ e! h V0 |$ l
Item item = results.getItemByIndex(i);
" r' {/ Y0 [ P1 | content += "" +
( W3 K4 r" v; ]0 a4 E2 K "<tr>" + 3 L, l0 C" c) f. D, P+ r! ^4 a
"<td>" + item.getProperty("item_number") + "</td>" +
% h. P- M- E! V7 n2 ]# v$ B5 T "<td>" + item.getProperty("description") + "</td>" + 1 E2 y$ T7 j9 Q
"<td>" + item.getProperty("cost") + "</td>" + A+ [. \4 i7 J6 Q' X. G; w
"</tr>";
$ E) y; h4 f: Q1 F} $ p2 {8 T3 k, G: [
content += "</table>";
1 s2 }; U/ e: ?( Y0 K8 w7 H yInnovator innovator = this.newInnovator(); % }0 `) O! ^$ Y
return innovator.newResult(content); - K, Y0 q' s, K$ k9 |% d! @' g
0 {2 H- o0 B( J
VB.Net
; O9 i8 ?1 o8 aDim qryItem As Item = Me.NewItem("Part","get") 4 j- F8 Z/ s8 N5 K8 J7 n
qryItem.SetAttribute("select","item_number,description,cost") ' i9 `6 l L- d2 j% L) J& e2 y
qryItem.SetProperty("cost", "100", "gt") . G* E! z$ l9 q# p
Dim results As Item = qryItem.Apply()
o6 @& b8 U+ X% }Dim count As Integer = results.GetItemCount()
: m3 ]1 P. ~3 i* [9 Y' ^# \5 ]3 N5 \Dim i As Integer
- }7 w# A7 p! Y, C* x. ]Dim content As String = "<table>" ' t, b2 R& e. i/ k2 m( E
For i=0 to count - 1 # b" l2 F$ a7 r) F, `% v
Dim item As Item = results.GetItemByIndex(i) `) X8 _) r% W% U) Z7 p
content += "" + _ * K. _3 M3 F3 S5 c; Y" U
"<tr>" + _
3 v+ L3 X4 ~- }0 d7 d8 I( S1 s "<td>" + item.GetProperty("item_number") + "</td>" + _ $ X" u) R1 J z% X
"<td>" + item.GetProperty("description") + "</td>" + _
8 t* g# d" q" e1 F "<td>" + item.GetProperty("cost") + "</td>" + _
( a" z/ M0 F8 O "</tr>" / k8 f9 }+ F/ D, r2 c4 W, A
Next
3 W$ N3 L1 W% e" o. |2 Pcontent += "</table>" `& I' |1 u5 K+ p* N
7 t6 J( h0 I6 L* A; Q7 m4 ~" I6 FDim innovator As Innovator = Me.NewInnovator() 3 i: O. q) r2 M8 K* q6 N6 m/ z
return innovator.NewResult(content) 7 i0 d1 [' o% P0 r
8 i% V3 e' f( c. T8 {
, u) m% I+ r. k; j" P1 L, P |
|