PLM之家PLMHome-工业软件践行者

【Aras二次开发】查询和迭代查找item集

[复制链接]

2018-8-1 13:37:47 1540 0

admin 发表于 2018-8-1 13:37:47 |阅读模式

admin 楼主

2018-8-1 13:37:47

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x

3 m: E3 Y8 }; \5 ?& g9 n& x7 w- H2 M" c( L) _; ]

! G9 `. O& _! P+ D
4 z$ }$ Q$ ~) |- x$ h  Z/ X: j
Technique  
" H" T* y, c6 BThere is no difference in setting up a query for a single Item or for many.  Only the : v* _, P$ x  o* A7 u2 V
criteria define the set size returned.  In this recipe you create an Item and populate / ?5 ?8 s: X1 Q: d2 Q
the query criteria, apply it, and iterating over the Items returned producing a HTML
3 f7 i+ z7 F1 t! T, l<TABLE>  fragment.
$ |, r3 r. v" G9 m9 A4 H2 i' D$ @: |) r- ^! r

7 g: V- x0 i' u# cJavaScript  1 A) K7 n5 B, [* s/ X0 l3 R
var qryItem = this.newItem("Part","get"); 7 \1 @! x2 N  l+ J
qryItem.setAttribute("select","item_number,description,cost"); 1 p! K6 t# J! z5 l( G
qryItem.setProperty("cost", "100", "gt");
. N$ ?( {; ?% y2 dvar results = qryItem.apply(); ! ?2 J4 A; s' ]$ a; H# Y3 R
var count = results.getItemCount(); ) x) [, D8 j4 g! [( P
var content = "<table>"; ' t7 Z2 c( c, G  O
for (var i=0; i<count; ++i) . s- f5 Q0 [' Y0 r# ^
{
( i* K( b7 F) k9 u  var item = results.getItemByIndex(i); : T1 J0 L) R, N) d
  content += "" +
; A- G! j" Y" F7 G    "<tr>" +
: d+ {/ B& t+ Q1 k. l& `      "<td>" + item.getProperty("item_number") + "</td>" + 8 U# p+ D) {1 S6 N! K
      "<td>" + item.getProperty("description") + "</td>" +
1 q, a& G1 M5 x  |8 ]6 @      "<td>" + item.getProperty("cost") + "</td>" +
% x- S0 {- X+ U/ Z) {    "</tr>"; $ J0 R1 U/ z: |! o$ @
} - k% ^5 J5 b4 A. b. ~6 n# \) ]
content += "</table>";
& D; b; h9 }# g( H5 }4 Rreturn content; / O2 [: \* B4 F+ q

+ O% [3 i/ W  e8 J$ BC#  
" I, B% _$ n3 e/ M/ Z  KItem qryItem = this.newItem("Part","get");
/ @" S/ |2 T9 M' y9 ^: ~qryItem.setAttribute("select","item_number,description,cost");
- E8 D! ^* N4 j1 a/ M8 `  Y( P+ XqryItem.setProperty("cost", "100", "gt"); % b) }3 n' U" {/ |
Item results = qryItem.apply(); ! K. e0 D1 A+ d6 @
int count = results.getItemCount();
7 n! u5 n, ^- kint i;
* |7 F# p# o6 W4 Xstring content = "<table>"; ) I/ H7 d) g0 j+ v, E
for (i=0; i<count; ++i)
/ Y4 s/ G* P& m2 L5 x3 Z0 p{ 9 Q# J3 H2 ^- b6 I, J. I
  Item item = results.getItemByIndex(i);
+ J1 K7 D2 d0 d9 a3 u1 J  content += "" + 2 |+ S/ N, j& R; A9 w7 {
    "<tr>" + 2 V& r. d! y. w- A
      "<td>" + item.getProperty("item_number") + "</td>" +
7 v5 L: R  I9 R! u( ?      "<td>" + item.getProperty("description") + "</td>" +
" S+ R: q# h$ \3 I2 j9 K      "<td>" + item.getProperty("cost") + "</td>" + ( O4 V4 q9 R# ^8 S. |8 _8 U! l% n
    "</tr>"; # m( g7 \8 ?9 W5 y
}
2 \0 o( `" f+ ]' W0 qcontent += "</table>";
: Z* \% g8 a5 ^3 S3 BInnovator innovator = this.newInnovator(); * E- _. b3 s0 L6 @  M
return innovator.newResult(content); 7 {. M- G- y: e: u% J+ S' u

" E& t7 N; }2 MVB.Net  / Q, K& g0 U8 G
Dim qryItem As Item = Me.NewItem("Part","get") ! E0 H; S* F: Z4 B3 o1 T
qryItem.SetAttribute("select","item_number,description,cost") ) N% t( h' U+ x7 W- G8 J9 j
qryItem.SetProperty("cost", "100", "gt")
: N* U$ Q- J4 ~4 i) @Dim results As Item = qryItem.Apply() 6 h% Z' P; [$ F6 T
Dim count As Integer = results.GetItemCount()
$ S9 d: {2 ~+ r% H8 LDim i As Integer * `. A5 y( L+ ?4 c- K, m4 Y, T
Dim content As String = "<table>" 3 p, j) N9 a( J4 K! v- u6 c* Q' y
For i=0 to count - 1
6 {3 E$ {3 @$ Z  Dim item As Item = results.GetItemByIndex(i)
5 X1 }! Y1 U+ N  content += "" + _
; A- B; R9 N( `9 m    "<tr>" + _
- N  ?; e+ d3 C* O9 {! }      "<td>" + item.GetProperty("item_number") + "</td>" + _ 7 b' I. \# c$ K7 z; q& d
      "<td>" + item.GetProperty("description") + "</td>" + _
8 E( M: I, d& D' |* H      "<td>" + item.GetProperty("cost") + "</td>" + _ 2 I6 g/ t9 }4 v9 P) R* u
    "</tr>"
8 i2 a7 f# y9 j: b8 l& ^Next
6 _# w* |/ L( Q: j" k$ scontent += "</table>" * P2 z* z2 ~, k$ n& }6 g
; b2 c3 p+ `  l* ]; @$ v
Dim innovator As Innovator = Me.NewInnovator()
  |; z9 z; q; f9 Z* }7 J0 Greturn innovator.NewResult(content)
& z* Q5 |. r6 J' v4 D: z: v* E4 v
, Q) \& x3 {* W. q* ]7 l
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了