I have a report that pulls a list of employees from a database, this database has URL links to an image of themselves. Users are not required to upload an image, therefore in some cases when trying to load an image there will be a 404 error. I am trying to set up the image element in the table to load the image if it exists and to take a local default image if there is a 404 error. I'm trying this expression in the ImageUrl Properties
if(isNull(fields.Picture),noImage.png,Fields.picture) <-- Not certain if the isNull is the method I should be using but I can't tell because I an encounter before it even runs.
this returns with an Unable to resolve expression type, unable to find context scope for Id<noImage>.Id<png>
Is it possible to do what I am trying to achieve within the Infragistics reporting?
You are missing a couple of commas, try with if(isNull(fields.Picture),"noImage.png",Fields.picture).
That works for getting to the image, the isNull portion does not though (If i flip the noImage.png and Fields.picture it will load the noImage). I guess because it get's a 404 error it does not necessarily mean it is null. Now I just need to figure out how to check if it is a 404 error.
Could this work: I create a C# class the checks if the URL is valid, if valid returns the URL, if not valid returns the URL of my default image. If so how do I enter it into the Expression Assistant? I have tried
None of these have worked. Am I headed in the right direction?
Hi Christopher,
With an object data source, you can have the method as part of the model object that is given in the data source, and then access it via Fields.MethodName().
With a SQL Data Source, you can use a Runtime Data Source Provider, and return an IEnumerable of objects instead of the SQL rows. In those objects, add a method or property that does the 404 check. Finally, use Fields.Method() or Fields.Property to access the data (the designer may complain that the expression is not valid, but it should work on runtime).
Regards,Héctor
Hi Héctor ,
I've built out the Runtime Data Source Provider, my switch statements look like this,
switch (name) { case "Picture": buildUser newBU = new buildUser(); return newBU.buildUsers(); <-- returns="" a="" list="" br=""> default: // Ignore this provider for this data source return null; }
Basically in the case Picture, the buildUsers will return a List of type Users, all this contains is objects of type user that contain the url to their image. There is work done with in the process of creating the list of type User where it checks if the URL is valid. All this seems to work well, I just don't understand the exact process of having the report load from the Runtime Data Source Provider. It seems like that the report should automatically pick up data from the Runtime Data Source Provider by the expression you use in the report file. How exactly do I figure out what the correct expression is to fire the Runtime Data Source Provider?
Thanks,
Chris
I went into Data Source Configuration Wizard and selected the Object Data Source and I navigate to my buildUsers list and when I select it, it returns with this error: The selected type does not contain any public properties.
Any suggestions?
EDIT: The field in User that contains the URL is public.
Can you try creating a public and static method?
So currently I have a static method that takes two parameters, first and last name. All this does is returns the proper URL from the list in an IENumerable because for some reason I can't seem to have the report viewer iterate through the IEnumerable with more than one "User". So currently I can have the Report Data Explorer load in the Object Data Source and then it asks me to choose what the arguments for the method should be. I'm not entirely sure which one to choose, I've tried the Set Constant Value where I fill in the Arguments Value with the =Fields.FirstName and =Fields.Surname to pass the first and last names. This does not seem to be the correct approach as it loads the default image, which is the case for when it cannot find a user. I also have tried the Dynamic Parameter but to no avail.
It works with a standard method and the static methods to prepare the IEnumerable of user urls. The only thing is the report viewer does not iterate through them. It constantly loads the first image for each row of the report.