简体   繁体   English

动态ax x ++网格修改方法

[英]Dynamics ax x++ grid modified method

I would like to ask a quastion. 我想问一个问题。

Lets say that I have a grid in form. 让我们说我有一个网格形式。 In this grid I have two fields. 在这个网格中我有两个字段。 The first field is the orderId and second field is the invoiceId. 第一个字段是orderId,第二个字段是invoiceId。 Each field has already an overloaded modified method. 每个字段都有一个重载的修改方法。

Lets say that my requirment is that if you fill the orderId in first field then the invoiceId should automatically filled in field 2. and the same should happend in the opposit way. 让我们说我的要求是,如果你在第一个字段填写orderId,那么invoiceId应该自动填写在字段2中。同样应该以对立的方式发生。 If I fill the invoiceId then automacally the related orderId should be automacally in field1. 如果我填写invoiceId然后自动地相关orderId应该在field1中自动填充。

If for example comment out the related code of one method then works fine but only in one direction. 例如,如果注释掉一个方法的相关代码,那么工作正常,但只能在一个方向上。

But if I want it to work for both direction my ax client stop working. 但是,如果我希望它为两个方向工作,我的斧头客户端就会停止工作。 Looks like an infinity loop through modified methods and the debuger cannot help me. 通过修改的方法看起来像无限循环,debuger无法帮助我。

My quastion is...Exists any proper solution for this modified methods overlaping problem? 我的问题是......存在任何适当的解决方案,这种修改后的方法会覆盖问题吗?

modified()// method for invoice Field
{
   SalaryProvRevisions table = SalaryProvRevisions_ds.getFirst(1) ?    SalaryProvRevisions_ds.getFirst(1) :SalaryProvRevisions_ds.cursor();
   table.OrderId=SalarayProvInvoiceHandler::getOrderIds(table.InvoiceId);
.
.
.
.
}

modified()// method for ordeid field
{
   SalaryProvRevisions table = SalaryProvRevisions_ds.getFirst(1) ? SalaryProvRevisions_ds.getFirst(1) : SalaryProvRevisions_ds.cursor();
   table.InvoiceId=SalarayProvInvoiceHandler::getInvoiceId(table.OrderId);
.
.
.
.
}

of course this story has some others problems like one orderId can be related with a lot invoiceid.. but already solved them. 当然这个故事有一些其他的问题,比如一个orderId可以与很多invoiceid有关..但已经解决了它们。

Thanks a lot, 非常感谢,

Nikos 尼科斯

Your modified methods has no call to super() in the start of the method which may be the reason. modified方法在方法的开头没有调用super() ,这可能是原因。 Also you methods as listed do not compile due to missing return type. 此外,由于缺少返回类型,您列出的方法无法编译。

I will advise you to do your customization in the modifiedField method of the table. 我建议你在表的modifiedField方法中进行自定义。

public void modifiedField(FieldId _fieldId)
{
    super(_fieldId);
    switch (_fieldId)
    {
        case fieldnum(SalaryProvRevisions, OrderId):
            this.InvoiceId = SalaryProvRevisions::getInvoiceId(this.OrderId);
            break;
        case fieldnum(SalaryProvRevisions, InvoiceId):
            this.OrderId = SalaryProvRevisions::getOrderId(this.InvoiceId);
            break;
    }
}

I would move the location of the get methods to table itself where they truly belongs. 我会将get方法的位置移动到它们真正属于的表本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM