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?
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
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
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?
I am fairly new to using Visual Studio and MVC, so where exactly would this method be located? Would I implement this in to the igr files in some fashion, or would this method be located somewhere else? Thanks for your help so far!
Edit: I'm using a SQL Datasource so I'm not sure if your proposed approach would work, please correct me if I'm wrong.
If you are pulling the data from an object data source, you could add a method that checks for 404 and then call it with the expression language when binding to the ImageUrl property.