PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2018-8-1 13:37:47

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

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

x
/ O1 r$ e- m  t! P0 a

' I$ d; p: M' T7 A. f3 z* @4 X4 z, P5 J# f9 G3 Q) e

# @9 y7 o: {/ g1 qTechnique  4 ~3 Y2 S7 R# _+ F, f( D; w
There is no difference in setting up a query for a single Item or for many.  Only the
! `. D8 K0 V8 ^+ [- H, scriteria define the set size returned.  In this recipe you create an Item and populate ( ~  w, [( r. X# E, I- T
the query criteria, apply it, and iterating over the Items returned producing a HTML
3 T! u" H6 o$ ~<TABLE>  fragment.
" ?1 I5 N1 K! i5 z8 F; y$ q* \4 Y
+ N3 t$ N1 f- o4 |
JavaScript  
, m+ n6 {: b* vvar qryItem = this.newItem("Part","get");
8 `; Z8 v1 c1 v; N9 z1 [qryItem.setAttribute("select","item_number,description,cost");
+ C: K! @' k5 }8 j! [7 P! }* Q* CqryItem.setProperty("cost", "100", "gt");
' C4 ^2 @8 W  T$ Q( F4 Gvar results = qryItem.apply(); ' ^$ H8 H- ~5 j
var count = results.getItemCount();
' n' I  t7 }7 `8 Tvar content = "<table>"; / O% Z- K$ R, e9 D6 M
for (var i=0; i<count; ++i)
. b6 t, q8 t6 i% f: I{ % c5 ?0 I! S9 [' s
  var item = results.getItemByIndex(i);
+ H  |7 H9 L8 e4 E5 R% c4 T) j  content += "" +   k% R/ p" _4 t, a9 y* o
    "<tr>" + 2 X/ `/ }. y: `; c  y4 \
      "<td>" + item.getProperty("item_number") + "</td>" + / x" ?1 D: n% L, M2 [, o
      "<td>" + item.getProperty("description") + "</td>" + / O# D! m' j. F9 c5 Y* T: w$ f
      "<td>" + item.getProperty("cost") + "</td>" + ' |6 H/ D  c# R3 B7 n4 ]
    "</tr>";
9 S" j5 I6 g! V- b4 l& ~}
" C& i9 E8 F7 {4 w( kcontent += "</table>";
* M- U/ {- Q& y7 z" I- T9 S! Oreturn content; # }# ?. p/ v& W9 s' f0 N+ K

2 \. V3 Z6 i: c$ k* ]. FC#  6 O( x: q7 T) M! e
Item qryItem = this.newItem("Part","get");
# i/ h* t9 s% x2 VqryItem.setAttribute("select","item_number,description,cost");
, x/ k7 x* N5 P  q. E3 q, [  x7 LqryItem.setProperty("cost", "100", "gt"); : d: ~( x8 B% A
Item results = qryItem.apply(); ' w5 K$ ^7 U2 p2 E  m
int count = results.getItemCount();
# A- ~! q$ ^0 z0 Yint i;
' A: s. D% m) o, D7 o3 ?string content = "<table>";
, N; L4 Z3 O' {/ g5 J4 {) r7 rfor (i=0; i<count; ++i) % T+ J* H6 H! O& |4 G+ T' O! C$ |
{ 5 \# f/ Q  |. e# @2 a
  Item item = results.getItemByIndex(i);
* d, M9 K9 r: [( q  content += "" +
9 {) j: k( o" A% C1 S$ U; p# H8 t    "<tr>" +
8 A9 S; T% e' C! B$ k+ |4 n      "<td>" + item.getProperty("item_number") + "</td>" + 5 J3 R+ r  F' O0 k9 M6 _
      "<td>" + item.getProperty("description") + "</td>" +
' x/ x) E4 u# C" M9 |      "<td>" + item.getProperty("cost") + "</td>" + 9 j/ ~" a4 |% J7 ?8 Z
    "</tr>";
$ J7 h$ X6 z, }! E' H} # ?% d5 x% b* u# J% G! u
content += "</table>";
" c6 C" D2 i$ e- ^% v0 Z1 {: E" ?Innovator innovator = this.newInnovator();
  L/ J6 L% a3 ]/ Sreturn innovator.newResult(content);
" l. B7 d& ~% `2 B2 e0 Y
+ _1 L& E2 e, x8 O+ ^" {5 y6 z# WVB.Net  
+ i5 I0 R! v$ m- P2 B6 w' }1 }& D" rDim qryItem As Item = Me.NewItem("Part","get")
! ~. w, @5 t* ]+ D  C5 hqryItem.SetAttribute("select","item_number,description,cost") # N( T. J$ u! D; R
qryItem.SetProperty("cost", "100", "gt")
. a' X7 _5 }% v1 G, W2 U* [Dim results As Item = qryItem.Apply()
3 D. u" V3 u$ C  `" }6 U$ \+ [Dim count As Integer = results.GetItemCount()
) v3 f2 ^: k9 O5 e; I; j# RDim i As Integer # E- K  |+ L9 M( Q: b- Z5 ^9 ^) Q
Dim content As String = "<table>"
$ W2 P% W: n. d7 H( O$ T! m: OFor i=0 to count - 1 ' n/ _' S1 v4 h% K, Z
  Dim item As Item = results.GetItemByIndex(i)
: [" r4 @( {+ p% A( h  content += "" + _
$ ~( z( P: p3 e4 N, Y    "<tr>" + _
$ c& b( e6 G- H6 K      "<td>" + item.GetProperty("item_number") + "</td>" + _ 7 ?$ w6 Z: D* I8 p- N, Z/ q, `" Y
      "<td>" + item.GetProperty("description") + "</td>" + _ % q% H8 w! P( F" h4 v& [" s
      "<td>" + item.GetProperty("cost") + "</td>" + _
+ {5 ^% v  p- F, ]( Y* a    "</tr>" ) k* B7 e6 y3 w7 x
Next " Y6 g  z1 ^$ T; ^, D9 d
content += "</table>"
! s, @! o7 @  j8 }2 H, a - z2 S. Y8 F& E0 m
Dim innovator As Innovator = Me.NewInnovator()
4 ^7 {5 g5 E& ~& u4 e0 ]return innovator.NewResult(content) ' P9 k' B6 l( q9 V$ _3 w
3 D( M: M$ }6 m* l9 t; T1 L
" `5 ?/ B% Q# l1 ^6 D& a6 M* U
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了