Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John C Scott 473 posts 1183 karma points
    Feb 28, 2011 @ 09:53
    John C Scott
    0

    list all approved forms in a dashboard control

    i'm looking for a tip to list all submitted forms in a dash board control

    i want to write a dashboard ascx control that lists all submitted form entries with a drop down to select which form but i'm not sure which library to use in c# to get all record sets for a specific form guid that have been approved

    there will then be a link that passes the guid of that form to a page i've created that passes the form data for each form to another page - so i will store the guid of the form i want to list and get a list of all the entry guids for that form

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Feb 28, 2011 @ 13:49
    Tim
    0

    There's a couple of ways of doing this. One is to just use XSLT and do a transform to turn the data into HTML. The methods for that are in the Umbraco.Forms.Library namespace. The other is to use the RecordStorage and RecordViewer methods. In my experience, the XSLT stuff tends to be a lot faster if you're just pulling out the data to display (although its harder to bind it to a DataGrid for example). The Developers Guide has some information on some of these methods, you can download it from the project page: http://our.umbraco.org/projects/umbraco-pro/contour

    Hope that helps! If you need help with the RecordViewer/Storage syntax, let me know, as that's not as well documented as the library methods.

  • John C Scott 473 posts 1183 karma points
    Feb 28, 2011 @ 20:36
    John C Scott
    0

    thanks Tim - yes I am finding the XSLT dead easy to use, but the C# for the ascx seems a bit more tricky, wondering what's the best way to use the record viewer to get the approved entries for a specified form

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Mar 01, 2011 @ 09:56
    Tim
    0

    I'm not sure about the best way, but here's some code I've used to list all of the records for a form:

    Umbraco.Forms.Data.Storage.RecordStorage rs = new Umbraco.Forms.Data.Storage.RecordStorage();

    List<Umbraco.Forms.Core.Record> list = rs.GetAllRecords(formId); //formId is the GUID of the form you want the records for

    You can use LINQ to filter the list to just the approved ones. There are some other methods that allow you to get the records by status, but they don't seem to work properly, apparently they're depracated.

     

  • John C Scott 473 posts 1183 karma points
    Mar 02, 2011 @ 09:27
    John C Scott
    0

    Thanks for that Tim, that should do the trick.

    I've got to admit the simplicity of using XSLT has persuaded me to maybe change the approach and build this as a page and not a dashboard control. It makes it easier to determine which forms have the feature available. But I'm a bit confused by passing a page ID rather than a form GUID. Can't quite get my simple head around it. Surely the same form could be inserted on more than one page? Also if you want to list the forms that are not on the same page or offer a choice is there a way to pass the form guid instead of the ID the page is on? In asking the question I am seeing this could work fine, but just checking I am understanding this right. Is it the ID of the page you have inserted the form on? Is this as in inserting a macro into an RTE? Presumably this means you can only have one form per page too?

    Thanks again for your help, it's great to hear from you again, your business card kept the designers at work entertained too, so hoping that is a good thing :)

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Mar 03, 2011 @ 12:53
    Tim
    0

    Hehe, glad the card was appreciated!

    :P

    Sorry for not getting back to you sooner, I was off yesterday! You're right, the same form can be on multiple pages, some of the library methods are a bit confusing though, as they want the page that the record is on, rather than the form GUID.

    If you're using an XSLT macro to build the list, you should be able to use: umbraco.contour:GetRecordsFromForm(form guid here as string)

    I'm not sure off the top of my head what the equivalent code call would be in C# though.

    :)

Please Sign in or register to post replies

Write your reply to:

Draft