1

Topic: How to add Edit and View Details links to an Explore Records grid in

How can I add links for Edit and View Details to an "Explore Records" grid, as appear in the iRecord "Explore My Records" form? I'm guessing this involves adding a column for an Actions List in Column Configuration in Report Settings - but I don't know what exactly to add to the Actions List.

I can't find anything in the tutorials on this.

Many thanks

Alan

Alan Hale
Aberystwyth

2

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Alan,

Let me point you at the API documentation for the report_helper class where you want to read about the columns option for the report_grid function. You may find this, for once, slightly easier to read by looking at the comments in the source code.

Taking the example of http://www.brc.ac.uk/iRecord/index.php?q=all-records and looking at the columns configuration list the setup, if I click the Edit Source link below so I can paste it here, is as follows.

[
  [
    {
      "display":"Actions",
      "actions":
      [
        {
          "visibility_field":"belongs_to_user",
          "url":"{rootFolder}enter-record-list",
          "urlParams":
          {
            "occurrence_id":"{occurrence_id}"
          },
          "img":"{rootFolder}/sites/all/modules/iform/media/images/nuvola/package_editors-22px.png",
          "caption":"Edit this record"
        },
        {
          "caption":"View record details",
          "img":"{rootFolder}/sites/all/modules/iform/media/images/nuvola/find-22px.png",
          "url":"{rootFolder}record-details",
          "urlParams":
          {
            "occurrence_id":"{occurrence_id}"
          }
        }
      ]
    }
  ]
]

Um, not very easy to read. Let me add a screen shot of it.

That should give you something to ponder.

Jim Bacon.

Post's attachments

action-columns.jpg 101.81 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

3

Re: How to add Edit and View Details links to an Explore Records grid in

Thanks Jim - I think I get it. Will report back.

Alan

Alan Hale
Aberystwyth

4 (edited by Alan Hale 18-03-2013 13:29:24)

Re: How to add Edit and View Details links to an Explore Records grid in

OK, a couple of things first off:

1) The img file on my installation is at /sites/all/libraries/iform/media/images/nuvola/find-22px.png (rather than in /sites/all/modules etc.)

2) The {rootFolder} token doesn't seem to add anything - so the path to my image becomes http://sites/all/libraries/iform/media/images/nuvola/find-22px.png  and it's not found. Neither are the record details

Cheers

Alan

Alan Hale
Aberystwyth

5 (edited by Alan Hale 18-03-2013 16:44:50)

Re: How to add Edit and View Details links to an Explore Records grid in

I notice that if I use {currentUrl} instead of {rootFolder] the path to the image is found:

{currentUrl}../../sites/all/libraries/iform/media/images/nuvola/find-22px.png

But I haven't yet figured out how to get to the record details using this (if indeed that is an acceptable way to do it).

Alan

Alan Hale
Aberystwyth

6

Re: How to add Edit and View Details links to an Explore Records grid in

I'm still struggling with this.  {rootFolder}record-details just takes me to an about:blank page.

Cheers


Alan

Alan Hale
Aberystwyth

7

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Alan

Two things to check.

First, if you go to your Columns Configuration List, click the Edit Source link below it and paste the results here we can check your configuration to see if we can understand why {rootFolder} is not being substituted.

Second, what you are doing here is creating a link to a page on your website. You need to have created that page before the link will work. If your page does not have the path, record-details, then you need to modify your configuration accordingly.

Jim Bacon.

8

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Jim

When I click on Edit Source I get nothing - nothing at all!

Cheers

Alan

Alan Hale
Aberystwyth

9

Re: How to add Edit and View Details links to an Explore Records grid in

Hi

Do you think if we just go home now the elves will come and fix it for us in the night?

If not, can you send a screen shot like the one I did above?

Jim Bacon

10 (edited by Alan Hale 21-03-2013 18:37:50)

Re: How to add Edit and View Details links to an Explore Records grid in

I can see there is a record details xml report and I can incorporate that into a grid on a pre-built form. i assume to get the details nicely laid out as in iRecord I'm going to have to build adapt a form form with some custom CSS?

In the meantime I've got a record-details form that accepts a record id parameter that I can use for testing - when we've sorted out {rootFolder}

Cheers

Alan

Alan Hale
Aberystwyth

11 (edited by Alan Hale 21-03-2013 20:44:26)

Re: How to add Edit and View Details links to an Explore Records grid in

Whoops! Overlooked your last response.

Here's a screenshot. Let's see what the elves can do :)

Alan

Post's attachments

col-config.jpg 64.23 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.
Alan Hale
Aberystwyth

12

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Alan

I've been trying to recreate your problem, using Instant Indicia 0.8.2, but cannot.

I have two thoughts.

1. Simplify so that nothing but the Action column is included. I note there is a whole extra bit to your columns config that is cut off the bottom of the screenshot - I can just see the top of a box with a 1, hinting at its presence.

2. Browser incompatibilities. What browser are you using? Does the jsonwidget that is used to create the column configuration play nicely with your browser?

Jim Bacon.

13

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Jim

Yes, looks like one issue is the browser - I tend to use Chrome most of the time. It seems like this is what is preventing me viewing the source - going over to Firefox I can do that.

I had an additional tab with another grid, so I've got rid of that for simplicity and here is the source as it looks now:

[
  [
    {
      "actions":
      [
        {
          "caption":"View Record Details",
          "img":"{currentUrl}../../sites/all/libraries/iform/media/images/nuvola/find-22px.png",
          "url":"{rootFolder}record-details",
          "urlParams":
          {
            "occurrence_id":"{occurrence_id}"
          }
        }
      ]
    }
  ]
]

I'm sticking with {currentUrl] for the img since this does at least allow me to see the button. In Firefox hovering the mouse over the button shows me that the link (for a row at randow) is to http://?q=record-details&occurrence_id=84, confirming that {rootFolder} is not being evaluated.

Cheers

Alan

Alan Hale
Aberystwyth

14

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Alan,
Have you tried leaving out {rootFolder}? I didn't use it and my link goes straight to my view details (enter-record-list) page so I assumed it wasn't necessary.

My code looks like:

[
  {
    "display":"Actions",
    "actions":
    [
      {
        "caption":"edit record",
        "visibility_field":"belongs_to_user",
        "url":"submit-list",
        "urlParams":
        {
          "occurrence_id":"{occurrence_id}"
        },
        "img":"/records//sites/all/libraries/iform/media/images/nuvola/package_editors-22px.png"
      },
      {
        "caption":"view details",
        "url":"enter-record-list",
        "urlParams":
        {
          "occurrence_id":"{occurrence_id}"
        },
        "img":"/records//sites/all/libraries/iform/media/images/nuvola/find-22px.png"
      }
    ]
  }
]

Hope this helps,
Fiona

Fiona McCrory
CEDaR Website Officer
www.nmni.com/cedar

15

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Alan

So we have a couple of questions to answer then.
1. Are we executing the same code.
2. If we are, what is happening differently.

There are two files that I am interested in, client_helpers/report_helper.php and media/js/jquery.reportgrid.js.
The former injects the rootFolder value in to JavaScript and the latter creates the links, making the subsitution for '{rootFolder}'

Using FileVerifier++ I get the following MD5 checksums. If you get the same then that confirms we are running the same code.

4f9445e07ed521f31be326a2ffa7dda2 report_helper.php
3a6bf612322c8283ee8b0e2c8800645c jquery.reportgrid.js

If you view the html source of your form you can find the value of rootFolder that has been injected by PHP. In my instance I find the following

  rootFolder: '/indicia/',

I've spotted a line of code in the JavaScript which, if {rootFolder} is omitted, will insert it. That is how it will be working for Fiona. However, if PHP is not outputting a value for JavaScript to use, this will not help.

Jim Bacon.

16

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Jim, Fiona

At your suggestion Fiona I tied leaving {rootFolder} out altogether, but that doesn't work for me.

Checking the source of my form reveals :  rootFolder: '//'

I've just installed FileVerifier++ but I don't immediately see how to get the checksums with it. I need to go out shortly so will look at this again later.

Cheers

Alan

Alan Hale
Aberystwyth

17 (edited by Alan Hale 22-03-2013 17:39:54)

Re: How to add Edit and View Details links to an Explore Records grid in

OK, I can report that the MD5 checksums for those two files are identical on my system to the ones you quote.

Cheers

Alan

Alan Hale
Aberystwyth

18

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Alan.

After painstakingly working through the code, understanding that there was a bug that was affecting you because, I deduce, your forms are in the webroot and not a subfolder, I find that John already fixed this problem a couple of weeks ago in revision r5375.

If you patch your copy of report_helper.php around line 621 with the indicated change then all should be well.

I do wonder if we shouldn't replace the entire iform module with the version in the development trunk rather than use the version in Instant Indicia 0.8.2. Instant Indicia 0.8.2 is just a development snapshot and many of the bugs I have been helping people with turn out to have already been fixed. The dev version would still be buggy but at least I wouldn't feel like I was wasting my time.

Jim Bacon.

19

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Jim

Thanks very much - that must have been galling.

Yes, I confirm my Instant Indicia installation is in the webroot, not a subfolder.

Making the code change you suggest  does fix the path to my record-details page. But very oddly not to the image file. However, I do now find (as Fiona suggested) that I can leave {rootFolder} out altogether and the correct path is generated.

From my point of view, at least I'm a step further on.

Cheers

Alan

Alan Hale
Aberystwyth

20

Re: How to add Edit and View Details links to an Explore Records grid in

Hi Alan

A value of

{rootFolder}sites/all/libraries/iform/media/images/nuvola/find-22px.png

for the img parameter ought to work for you since we now know {rootFolder} is going to resolve to / in your case.

Make sure that you do not put a / between {rootFolder} and sites as then you would have a double slash making a link that is interpreted as absolute rather than root-relative.

Jim Bacon.

21

Re: How to add Edit and View Details links to an Explore Records grid in

Ah, yes of course - I had put that extra / in. It now works. Thanks Jim.

Alan

Alan Hale
Aberystwyth