Partial view script in _grid.cshtml not working

Apr 26, 2013 at 8:47 PM
Edited Apr 26, 2013 at 8:48 PM
I just started with that grid and stumbled into access violations in my view when the script was executed:
    pageGrids.myGrid.onRowSelect(function (row) {
        $.post("/Home/GetOrder?id=" + row.OrderID, function (data) {
            if (data.Status <= 0) {
                alert(data.Message);
                return;
            }
            $("#order-content").html(data.Content);
        });
    });
Reason was, that the script in partial view _grid.cshtml was never executed - don't know why this happens because the sample works ..... Also, VS2012 indicates a syntax error in _grid.cshtml script!

Some other comments indicate partial views should not contain script at all, so I copied the partial script into the main view script and it worked.
This part should be analyzed in greater detail.
Coordinator
Apr 27, 2013 at 5:27 AM
Hi, can you provide more infomation about error?

You need to ensure that your page contains references to jquery.js and gridmvc.js in the <head> section
Apr 27, 2013 at 12:09 PM
OK, I haved move jquery.js and gridmvc.js in the <head> section - seems to work now.
You should consider standard behavior of script following html. By now, all pages in MVC4 will receive the reference to gridmvc.js

The Error: Image
I did not go further into both errormessages (VS2012 only calls it syntax error)
Coordinator
Apr 27, 2013 at 12:22 PM
Yes. now you need to reference gridmvc.js on each page, which renders the grid, because this script adds some client functionallity, like filtering popups. I will fix it in the next release.

Btw, it seems that you use the last repository version, which is not released. I recommend you to use the last 2.3.0 release: https://gridmvc.codeplex.com/SourceControl/changeset/view/23712