1、NC portal获取当前登录者vo数据:
LfwRuntimeEnvironment.getLfwSessionBean().getUserObj(CpUserVO.class);//获取当前登录者vo数据
2、NC portal给参照设置条件(添加过滤条件):
给参照设置值(过滤参照),先给参照设置监听
IRefNoderefNode =this.getCurrentView().getViewModels().getRefNode("phoneBvodef1_hrhi_0001Z7HI10PSN0000ZJ2");
NCRefNodencModel = ((NCRefNode) refNode);
ncModel.setDataListener(HrDeptRefModel.class.getName());
写一个过滤类,继承AppReferenceController这个类
packagenc.hrss.pe.phone.view;
importnc.bs.hrss.pub.tool.SessionUtil;
importnc.hr.utils.ResHelper;
importnc.pub.tools.HiSQLHelper;
importnc.uap.ad.ref.NcAdapterTreeGridRefModel;
importnc.uap.lfw.core.data.Dataset;
importnc.uap.lfw.core.refnode.RefNode;
importnc.uap.lfw.reference.ILfwRefModel;
importnc.uap.lfw.reference.app.AppReferenceController;
import nc.ui.bd.ref.AbstractRefGridTreeModel;
importnc.ui.bd.ref.AbstractRefTreeModel;
importnc.ui.pub.beans.ValueChangedEvent;
importnc.vo.om.pub.SQLHelper;
public classHrDeptRefModel extends AppReferenceController{
@Override
protected void processSelfWherePart(Datasetds, RefNode rfnode, String filterValue, ILfwRefModelrefModel) {
resetRefnode(rfnode, refModel);
}
@Override
protected voidprocessTreeSelWherePart(Dataset ds, RefNode rfnode, ILfwRefModel refModel) {
resetRefnode(rfnode, refModel);
}
/**
* 重新设置RefNode的值
*
*@param refModel
*/
private void resetRefnode(RefNode rfnode,ILfwRefModel refModel) {
String pkorgs =SessionUtil.getPk_org();
NcAdapterTreeGridRefModelncmodel=(NcAdapterTreeGridRefModel)refModel;
ncmodel.setClassWherePart(" pk_group= '"+SessionUtil.getPk_group()+"' and pk_org='"+pkorgs+"'");//过滤树型参照
//ncmodel.setClassWherePart(" pk_group= '"+SessionUtil.getPk_group()+"' and pk_org='"+pkorgs+"'");//过非树型参照
}
}
3、NC portal关闭当前窗口
//WindowContext windowContext =AppLifeCycleContext.current().getWindowContext();
//windowContext.closeView(""); // 关闭当前窗口
AppLifeCycleContext.current().getApplicationContext().closeWinDialog();
4、NC portal 获取当前界面主表(子表)的值
LfwView main = AppLifeCycleContext.current().getViewContext().getView();
//主表
Dataset datasParent=main.getViewModels().getDataset("headid");//获取当前视图某个表的数据集
Row row=datasParent.getSelectedRow();//获取当前行的数据(卡片型只有一行,获取当前行即可)
Object dataValue =row.getValue(datasParent.nameToIndex("djrq"));//获取对应字段
//子表
Dataset datasChild=main.getViewModels().getDataset("bodyid");//获取当前视图某个表的数据集
Row row=datasChild.getSelectedRow();//获取当前行的数据(卡片型只有一行,获取当前行即可)
Row[] rows=dataset.getAllRow();//获取所有行数据
Object dataValue =row.getValue(datasParent.nameToIndex("djrq"));//获取对应字段
5、NC portal获取按钮控件,控制其显示与隐藏
获取按钮控件,控制其显示与隐藏
LfwView main=LfwRuntimeEnvironment.getWebContext().getPageMeta().getView("main");
GridComp gridb=(GridComp) main.getViewComponents().getComponent("phoneBvo_grid");
MenubarComp mc=gridb.getMenuBar();
mc.getItem("phoneBvo_grid$HeaderBtn_Import").setVisible(true);//设置按钮的显示与隐藏,“phoneBvo_grid$HeaderBtn_Import”可在配置文件中找到对应的ID
6、NC portal保存只能获取当前子表选中行的数据集问题
保存是获取子表数据只能获取到当前选中的行
代码如下:
LfwViewmain=LfwRuntimeEnvironment.getWebContext().getPageMeta().getView("main");
Dataset bodyds =main.getViewModels().getDataset("phoneBvo");
Row[] bodyRows =bodyds.getAllRow();
解决:
上面代码不变,在对应节点配置文件保存按钮处增加一下配置
<Menus>
<MenuBarCompid="menubar">
<MenuItemid="save" modifiers="2" showModel="1" text="保存">
<Events>
<Event async="true"methodName="onSave" name="onclick"onserver="true">
<SubmitRule>
<Widgetid="main">
<Dataset id="phoneHvo" type="ds_current_line">
</Dataset>
<Dataset id="phoneBvo" type="ds_all_line">
</Dataset>
</Widget>
</SubmitRule>
</Event>
</Events>
</MenuItem>
<MenuItemid="sep3" modifiers="2" sep="true"showModel="1">
</MenuItem>
<MenuItemid="back" modifiers="2" showModel="1" text="取消">
<Events>
<Event async="true" methodName="onBack"name="onclick" onserver="true">
<Action>
</Action>
</Event>
</Events>
</MenuItem>
</MenuBarComp>
</Menus>
7、NC portal设置表头表体编辑性
LfwView main=LfwRuntimeEnvironment.getWebContext().getPageMeta().getView("main");
//表体
GridComp gridb=(GridComp) main.getViewComponents().getComponent("phoneBvo_grid");
GridColumn phoneno=(GridColumn) gridb.getColumnById("phoneno");
phoneno.setEditable(true);
//表头
FormComp formCompHead = (FormComp)main.getViewComponents().getComponent("phoneHvo_form");
formCompHead.getElementById("def3").setEnabled(false);//设置表格单元格编辑性
8、NC portal通过接口调用vo集(可以是aggvo)
IMDPersistenceQueryService service = NCLocator.getInstance().lookup(
IMDPersistenceQueryService.class);
NCObject ncObject1 =service.queryBillOfNCObjectByPK(PsndocAggVO.class, pk); //通过此接口可调用vo集数据(可以是aggvo),只需要主键即可
9、NC portal通过表头主键查询子表vo数据集合
//单据主键
String pk = (String)headrow.getValue(ds.nameToIndex(ds.getPrimaryKeyField()));
List<PhoneBvo>listvo=null;
try {
listvo = (List<PhoneBvo>)new BaseDAO().executeQuery("select *from hrss_phonefee_b where nvl(dr,0)=0 and pk_phonefee_h= '"+pk+"'", newBeanListProcessor(PhoneBvo.class) );
} catch(BusinessException e) {
e.printStackTrace();
}
10、NC portal获取按钮控件,控制其显示与置灰
获取按钮控件,控制其显示与置灰
MenubarComp comp = (MenubarComp) ViewUtil.getCurrentView().getViewMenus().getMenuBar("menubar");
comp.getElementById("edit").setEnabled(false);
原文链接:https://blog.csdn.net/qq_35532919/category_6779038.html