|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
) S% b: z: ?/ I1 x6 n* s' U
/ a% \& r% I4 q5 f* f
& ~# V. ~5 p* q$ p' r. q% u5 \; Q1 l, I5 W# p8 Z# ~9 [
Technique
+ Z5 \4 T/ e& V) m# T$ D6 _8 yThere is no difference in setting up a query for a single Item or for many. Only the
! N! o$ o% z5 g! F: [criteria define the set size returned. In this recipe you create an Item and populate
2 S" u4 L8 L+ R5 F. L* Pthe query criteria, apply it, and iterating over the Items returned producing a HTML R; I$ q! N' `6 `1 Q. T; w8 N+ L
<TABLE> fragment.
( t5 K+ k" x) R8 Z) @7 x: b* x% O: m* g3 _& ?
& [: r- q. L. N" ~; fJavaScript $ L+ I+ Q0 ~. u5 E% v; g9 I) E
var qryItem = this.newItem("Part","get"); 1 A4 _* W5 ~& h
qryItem.setAttribute("select","item_number,description,cost"); K, r' K( j7 R ^& Y$ P
qryItem.setProperty("cost", "100", "gt");
" h! n! U$ d/ H$ v7 _1 mvar results = qryItem.apply(); # K* [. K6 p& x
var count = results.getItemCount();
1 v' M& }2 Y+ J. k* a8 Lvar content = "<table>"; - w, I. ^- z4 `9 O9 V+ [) V0 {
for (var i=0; i<count; ++i) 1 x8 y0 m- i* V
{
, D# ^& I3 L9 F0 p: p+ p6 z2 Z var item = results.getItemByIndex(i); k! Z; ]; O. a9 v
content += "" +
- W, }+ K0 ~5 e3 C "<tr>" +
, ?3 q7 {0 s( L* m D2 w6 E5 |1 X" w "<td>" + item.getProperty("item_number") + "</td>" +
- b5 N1 E V- T& o" R "<td>" + item.getProperty("description") + "</td>" + # c5 H) ~6 O5 H
"<td>" + item.getProperty("cost") + "</td>" + ) Q4 w% n) H5 ~) j# I& s
"</tr>";
) p9 }$ ]3 Y9 y( n- i; Y9 E o, Q} 9 G- y( I& \5 n. J# o+ D e
content += "</table>"; 3 U+ O! d% a' o4 t9 ~
return content; ) K) U. h3 z( ~" ~! b
' W. q+ X$ F t2 D) s; \
C#
* r- N- J8 N+ z0 w+ R0 ^Item qryItem = this.newItem("Part","get");
3 u% B! J. @% f& C# l6 A$ B UqryItem.setAttribute("select","item_number,description,cost");
* A7 l4 v" N8 T3 v/ S# JqryItem.setProperty("cost", "100", "gt"); , P/ k3 y; i# s9 f- k
Item results = qryItem.apply();
% p' w- [; i/ |int count = results.getItemCount(); / z0 _9 Z/ m9 A* v) r% s
int i;
" [# j6 M% E5 @$ h; u2 c0 Y; ^string content = "<table>"; / E( L p, O. F7 Z( D% N) W
for (i=0; i<count; ++i)
5 `8 z. ^7 z; o v* H2 E4 S{ ; [8 B8 t( B0 N3 U
Item item = results.getItemByIndex(i); 1 H" }. @) `6 e
content += "" + ( P7 y$ A8 T3 b( X. X0 Z6 C
"<tr>" + ( [. r$ e, L7 U6 o+ n
"<td>" + item.getProperty("item_number") + "</td>" +
. ^, m, T% K6 ]8 A- N( T "<td>" + item.getProperty("description") + "</td>" + 5 z& e0 [% m* r Y5 }. H K2 r/ p, m
"<td>" + item.getProperty("cost") + "</td>" + ) B$ d& O9 p$ d5 Q* _$ s. b
"</tr>";
. M( u4 J- r" ~; S} L M" E" [3 N- C: J
content += "</table>";
' g1 I/ f6 z% s4 `" ZInnovator innovator = this.newInnovator(); - G, H' ?. t7 w+ w i5 T/ j/ \
return innovator.newResult(content);
, \& M# N2 s: I2 ^" L+ `7 | ; ]4 Z7 G, m$ i$ ]7 H
VB.Net 0 i( ? T; A4 m1 I* O/ s3 r, w
Dim qryItem As Item = Me.NewItem("Part","get")
I# b) v7 c% E& c, B9 cqryItem.SetAttribute("select","item_number,description,cost")
* e8 t }% I: a2 `+ hqryItem.SetProperty("cost", "100", "gt") 0 A+ K, _2 F( o# q* ^5 h% Y
Dim results As Item = qryItem.Apply()
5 |; i2 J x% y$ @Dim count As Integer = results.GetItemCount() / ^- e/ s" e, D6 ?# ]3 L
Dim i As Integer
7 K: x) n. K! [! ]Dim content As String = "<table>" 4 t7 _( d! @$ _5 H6 _( g) o% \
For i=0 to count - 1
2 b0 ~/ M! {% j: B Dim item As Item = results.GetItemByIndex(i) 6 d4 a) D. F) T5 Q* s
content += "" + _
* ]6 L4 H( S! e6 A3 _. h "<tr>" + _ + h+ y0 s( {# O# K4 m% o
"<td>" + item.GetProperty("item_number") + "</td>" + _ ' [7 _4 h+ t+ V# j
"<td>" + item.GetProperty("description") + "</td>" + _ 7 }1 `; {/ T) N, |4 a2 Y& e
"<td>" + item.GetProperty("cost") + "</td>" + _
4 t0 k% w! k6 m1 O "</tr>"
8 V O5 K' J9 j. }& L4 Y- VNext 7 G# C" b, v; m4 \/ `4 g
content += "</table>"
& W/ U" k" [3 I) w
7 E9 ^# |7 `) U: T4 @/ _, u2 x! GDim innovator As Innovator = Me.NewInnovator() 9 L# g$ u' P3 p
return innovator.NewResult(content) ! [5 t; T) j8 G) s+ m
1 r' \) S# \; z% `. V7 T
" r }1 ^) l$ {/ U' u2 w' N
|
|