Setting values for unbound elements - can't found InstanceModel

0
zonadowns posted this 06 March 2018

Hello, I'm new in the docentric world and c# programming. May I have your help please?

I'been reading this info https://www.docentric.com/documentation/examples/managing-code-behind help

It's says that we can populate unbound elements in the ElementInitializeEventHandler event, but the example use a instruccion comparing to an objet that I cant found the reference in my project with Docentric dll v5.1.26. the object instance is: InstanceModel.FieldElementInstance. Where is it?

The code is:

void dg_ElementInitializeEventHandler(object sender, ElementInitializeEventArgs e)
        {
            // Check if the current rendering element is the kind of Field element named as “AverageProductPrice” 

            if (e.Element is InstanceModel.FieldElementInstance &&
                ((InstanceModel.FieldElementInstance)e.Element).Name == "AverageProductPrice")
            {
                // Set the formatted value of the element 
                var products = DataAccess.GetProducts().Where(p => p.Category.Name == "Seasonings");
                ((InstanceModel.FieldElementInstance)e.Element).TextValue = products.Average(p => p.Price).ToString("n2");
            }            
        }

Thansk ind advance for your help.

Regards from Nicaragua.

3 Posts
3 Points
3 Comments
Order By: Standard | Newest | Votes
1
jles posted this 07 March 2018

Hi,

Thank for posting a question on this forum. You can find the types and all relevant namespaces in our documentation: https://www.docentric.com/documentation/programming/reference-guide

I'm sorry to tell you but the documentation is wrong. These types do not exist and this is why you didn't find them. Ujse the types from the following namespace instead: https://www.docentric.com/documentation/programming/reference-guide/docentric.documents.reporting.model

Please let me know if this helped and you made it work.

Since you are a newcomer, I would also recommend you to read the following blog article about choosing the right data source. Maybe this is something that might be useful for your project: https://www.docentric.com/blog/2016/01/28/choosing-the-right-kind-of-a-data-source/

Best regards,

Jure Leskovec

155 Posts
295 Points
0
zonadowns posted this 08 March 2018

Hi Jure,

Thanks. I Found this in a example and let's ready!

void DocumentGeneratorOnElementInitialize(object sender, ElementInitializeEventArgs e)
{                      
    if (e.Element.Name == "TotalRegistros")
    {
        // Set the formatted value of the element 
        //var products = DataAccess.GetProducts().Where(p => p.Category.Name == "Seasonings");
        e.Element.AsField().Value = CuentaRegistros;
    }            
}

The post in the Blog it's very helpful, I was wondering how to decide for the right Datasource.

Kind Regards,

Downs

3 Posts
3 Points
0
jles posted this 09 March 2018

Hi Downs,

I'm happy I was able to help. Just let us know if you will need our help again.

Regards,

Jure Leskovec

155 Posts
295 Points

Our 229039 members have posted 345 times in 102 discussions