|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 S/ m7 |, \: d6 z) M7 m/ S O7 |% X
6 R9 w; W* t( R/ [- ]; N4 k3 E1 H) R/ r6 n/ c( f( [" ]7 v* h4 f
. {- G0 }3 e3 z/ F9 kTechnique
# _$ U6 Q# y: R6 kThere is no difference in setting up a query for a single Item or for many. Only the : R, D5 j7 M# [6 ~2 `
criteria define the set size returned. In this recipe you create an Item and populate
, h. H8 V' G0 \1 u' Qthe query criteria, apply it, and iterating over the Items returned producing a HTML
# I$ w- Q- N4 Z2 { W<TABLE> fragment. $ C+ h4 e# \6 D9 o1 W
% s' M4 d: |8 ]( v4 |# ]6 a0 \/ ~( n
@" F/ w. m" F" LJavaScript 9 S5 i3 n- l x/ ~3 N+ e
var qryItem = this.newItem("Part","get"); , j' S2 F- s l1 p( K! A" {
qryItem.setAttribute("select","item_number,description,cost");
4 ^/ D! i1 M( O6 Y4 fqryItem.setProperty("cost", "100", "gt");
9 i: j4 U/ V1 E6 c: d- p" w+ |; Kvar results = qryItem.apply();
5 ?" b" t$ w, v5 t0 T$ ]var count = results.getItemCount();
0 a, D( d( o# N0 S" u& F7 n. |var content = "<table>";
8 O0 @: p, o/ ~7 u: c5 Hfor (var i=0; i<count; ++i)
* A$ s" R" K" k$ O- p/ ^3 c u7 U{
/ F, Q% H% a3 d( l var item = results.getItemByIndex(i); ( u- G8 q4 Q3 A2 i; \3 o
content += "" + / d8 D+ S' y4 R5 u$ h( ?
"<tr>" + ) M7 ?, I2 W, [- O' ]
"<td>" + item.getProperty("item_number") + "</td>" +
" c# i. m9 c7 L( n; @' A "<td>" + item.getProperty("description") + "</td>" +
1 S4 G$ j) Z6 D- n "<td>" + item.getProperty("cost") + "</td>" + ' F7 \3 m8 g) I8 N4 @. W
"</tr>";
- Z# e4 ?$ i1 v8 _) A0 V} 7 g% U% c# k. h
content += "</table>"; ; X9 _: V$ J( M6 r; q
return content; % Y v$ I( u4 J
6 `- E; q& g; J8 p' u9 xC# 1 k1 c8 I- d* k1 t' G2 o4 T
Item qryItem = this.newItem("Part","get");
6 O' P% ~4 D7 Z6 ]. sqryItem.setAttribute("select","item_number,description,cost");
" {4 N$ L6 \6 rqryItem.setProperty("cost", "100", "gt"); ( L9 C* {5 [9 L
Item results = qryItem.apply();
, l4 l4 h0 @7 f1 a0 f) R0 N1 w- x$ `int count = results.getItemCount();
* G5 _6 G5 \2 a( Pint i;
% n8 I' M" e3 M' }' d; Bstring content = "<table>";
5 S: w3 Y6 f8 _for (i=0; i<count; ++i)
% J! F3 g7 Z6 Q9 @4 G{
' s/ k- Z) n; f. g1 ~8 Y Item item = results.getItemByIndex(i); $ h" f6 k' i7 O6 E# c, _
content += "" +
/ v) B' p# H% ?2 ~, ~5 Q" J "<tr>" + 7 Z9 F, s7 P( W. V4 x j5 o/ x
"<td>" + item.getProperty("item_number") + "</td>" +
9 x5 @8 M% ?) }7 d5 h' @. L "<td>" + item.getProperty("description") + "</td>" +
V8 C: k b) ?- { "<td>" + item.getProperty("cost") + "</td>" +
3 @: r) a2 J! |+ _2 _ A5 n" m/ t6 y "</tr>"; 8 H$ j/ F4 }5 D# @/ w) f: K: H
} $ T p4 L# t j2 C0 b2 C; S: M
content += "</table>";
8 n3 }! H& \4 \; h1 K" G- W- [Innovator innovator = this.newInnovator();
3 @7 A6 `2 D" P A# preturn innovator.newResult(content); 3 v0 R4 p8 u" \9 Y; `. J
: N5 X: [& k/ {* I! v
VB.Net 3 {3 w0 ]6 m4 y, D4 P+ @+ |0 v
Dim qryItem As Item = Me.NewItem("Part","get")
4 F, }0 g% j' ~0 V4 F/ i5 ]qryItem.SetAttribute("select","item_number,description,cost")
# W! q, p1 m! H5 k: z7 f( Q8 N! {qryItem.SetProperty("cost", "100", "gt") * G0 N" ~- Z, \0 |/ ]
Dim results As Item = qryItem.Apply()
) {$ |# _. {) v: CDim count As Integer = results.GetItemCount()
6 W( o3 T" a% j. O: T* UDim i As Integer
$ [* W' l. |' a( f) kDim content As String = "<table>"
& A3 `$ C. [) |! p: }5 }For i=0 to count - 1
+ e1 r% A3 p' ]( @# `- N1 k Dim item As Item = results.GetItemByIndex(i)
+ [& E. P# X0 q& B content += "" + _
6 T; I: O V! Z# K" `/ V "<tr>" + _
7 t$ @: W$ w7 {, x/ G, h9 p "<td>" + item.GetProperty("item_number") + "</td>" + _
: w/ u+ S9 i, y) ~4 P7 ^: |: C6 |# J "<td>" + item.GetProperty("description") + "</td>" + _ 6 |% a9 ~3 |7 y4 I
"<td>" + item.GetProperty("cost") + "</td>" + _ ' j2 C! }5 B/ K/ n" D2 y
"</tr>"
. y* d2 P# ~2 N) z2 z7 M; ANext : N4 D' A+ m" u: `; l
content += "</table>"
8 M5 q9 m; l. F' C6 F& } " o: C, p0 ~) P! P T4 e
Dim innovator As Innovator = Me.NewInnovator() 4 I' \% H$ |, @) S4 H5 y$ i
return innovator.NewResult(content)
5 h1 ]# O3 ~- s" j, Z3 w6 _8 A/ T- s R) H: \
# l4 C, D+ _1 k |
|