0

I have a test case here where I think I covered pretty much every requirement I could find in the docs to enable viewing the grid row form like when selected in this example. I'm probably too deep into this now but I get no javascript errors/warnings at all to follow up...

I should doubleclick a record and get to view the gridrow but it's blackhole-ing me. I could use some fresh eyes on this issue. Nor the pager icon nor doubleclick seems to work.

Can anyone help me on my way? thanks for any help. If the code does error out when you try it I'm in the middle of trying something out, so I will make sure it's syntax checks out when done.

Glenn Plas
  • 1,608
  • 15
  • 17
  • 1
    You included minimized version of jqGrid 4.1.1 in your demo. To allow other to debug the problem you should use `jquery.jqGrid.src.js` instead. It would be better to use current version (4.4.1) of jqGrid if it's possible. By the way you use `beforeShowForm` in definitively wrong way as the callback of jqGrid. Additionally you should eliminate the usage of `afterInsertRow`, replace if to `rowattr` (see [the answer](http://stackoverflow.com/a/10531680/315935)) and use `gridview: true` (see [the answer](http://stackoverflow.com/a/12519858/315935)). – Oleg Dec 11 '12 at 00:05
  • Afterinsertrow does work fine though, but thanks for the pointers, I'll check them out! – Glenn Plas Dec 11 '12 at 08:01
  • 1
    To be able to help you one need *debug* your application. Could you replace `jquery.jqGrid.js` (minimized version if jGrid) to `jquery.jqGrid.src.js`? The file `jquery.jqGrid.src.js` is the part of zip file which you downloads [here](http://www.trirand.com/blog/?page_id=6). The `afterInsertRow` work of cause, but it works **much slowly**. In case of usage `afterInsertRow` every row will be placed on the page *before* calling of `afterInsertRow`. So the position of **all existing (not only new one)** elements need be recalculated every time. See above the link about `gridview: true`. – Oleg Dec 11 '12 at 08:53
  • Thanks for the good help but you seem to suggest there is a bug in the jquery grid plugin code, or that I'll have a need to debug that specifically. I have no indication for this being the case, I hardly ever need to debug outside my own code which is quite readable imho. The afterInserRow just adds 1 UI class to the rows who's date's haven't passed yet, but that comes as a leftover from another project, not really intented for this one. I do really appreciate your insights on this. – Glenn Plas Dec 11 '12 at 22:06
  • You are welcome! I can repeat at the third time that I could debug the problem if you just replace `jquery.jqGrid.js` to `query.jqGrid.src.js` in [your demo](http://byte-consult.be/log/events.html) You can use references to the files from my site: [jquery.jqGrid.src.js](http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.1/js/jquery.jqGrid.src.js), [grid.locale-en.js](http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.1/js/i18n/grid.locale-en.js) and [ui.jqgrid.css](http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/css/ui.jqgrid.css). – Oleg Dec 11 '12 at 22:20
  • I want be sure that the problem is not already fixed in the lost year. – Oleg Dec 11 '12 at 22:21
  • I'll do this asap (we are in the same timezone btw) after some sleep, I'm interested to know where this is leading to :) – Glenn Plas Dec 11 '12 at 23:04
  • 1
    OK! Till tomorrow, pardon, ... Till today. I need some sleep too. We are really in the same time zone and even not so far of each other. – Oleg Dec 11 '12 at 23:36
  • Ow man, this is weird. I just replaced the files you mentioned and it works directly, so guess my code was good... – Glenn Plas Dec 13 '12 at 13:23
  • 1
    It's good news! I can't see the error in your code, so I suggested to debug it. The best if the problem is already fixed. Congratulations! – Oleg Dec 13 '12 at 14:02
  • Tx alot, pretty weird conclusion, I'm happy I didn't have to do what Franz Noel suggested, I was pretty sure the code checked out vs the jqgrid docs. It's just another way of doing it imho. But as always it helps to get critized! Tx you both. – Glenn Plas Dec 13 '12 at 14:23
  • If you create an answer of your suggestion I'll accept the fix and update my question, I think I'll not be the only one hitting this. I remember having the same problem trying to insert records in an older project, I'm starting to think this is the same issue. I should have tried the latest source before posting perhaps. – Glenn Plas Dec 13 '12 at 14:25
  • OK! I wrote my answer which described the things which we discussed before in the comments. I hope it could be helpful for other people. – Oleg Dec 13 '12 at 15:42

2 Answers2

1

What your missing is the following code:

onSelectRow: function (id) {
    $(this).jqGrid('viewGridRow', id, viewParam);
},

Where it should be placed:

$grid.jqGrid({

    ... // Some code attribute

    onSelectRow: function (id) {
        $(this).jqGrid('viewGridRow', id, viewParam);
    },

    ... // Some more code attributes
});

Edit your custom javascript event.js. As soon as you have learned how to use it and apply it, select the row. Then, you should be able to pull a pop up or something else that you want to do. It means you are going to need a lot of reading on the specific onSelectRow attribute.

Franz Noel
  • 1,820
  • 2
  • 23
  • 50
  • I've made many things using onSelectRow, this was the only one that didn't fire (I put it under a doubleclick event later). Thanks for the input. – Glenn Plas Dec 11 '12 at 08:03
1

First of all I recommend you to replace jquery.jqGrid.js file which is minimized version of jqGrid 4.1.1 to jquery.jqGrid.src.js from the current jqGrid 4.4.1. In general you should always try to reproduce the same problem in jquery.jqGrid.src.js if you have it in jquery.jqGrid.min.js. jqGrid will be permanently changed, many bug fixes will be fixed and new features will be added. For example jqGrid 4.3.3 have fixed wrong calculation of the grid width in Google Chrome version >=19 described here. It was implemented fixes to support current versions of jQuery 1.6 and many many other things. The version jqGrid 4.1.1 is almost two years old, which is really much in the world of web.

Additionally I would recommend you never use afterInsertRow and always use gridview: true. The reason is the performance of the grid. It's very important to understand that working with elements on the page (the DOM elements) should be other organized as with any other variables known in the computer language. The reason is that if you make changes of one element on the page web browser have to recalculate position style etc of all existing elements on the page. At least the web browser have to verify all elements whether there need be changed. One names such procedure web browser reflow. I recommend you to read the answer where I describe the problem more details. In the same way you should try to reduce any loops in loadComplete or gridComplete where you enumerate all rows and make changes in many rows. In the way the performance of the grid will be reduced in many times. If you would use another style of writing the program it will be exactly clean and good to understand as before and it could work much quickly. In the answer for example you could find one real example of such transformation of the code.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Great stuff, appreciate it. Your reference links to rewriting code more performant are very interesting and made it more clear to me what exactly you where saying what was wrong. – Glenn Plas Dec 13 '12 at 15:53