robinvanderknaap / MvcJqGrid

Fluent jqGrid Html Helper for ASP.NET MVC
www.playground.webpirates.nl/mvcjqgrid
GNU Lesser General Public License v3.0
101 stars 74 forks source link

Split js and html code rendering. #22

Closed MichaelSL closed 11 years ago

MichaelSL commented 11 years ago

This is a feature request. Is it possible to split js code and html elements rendering? It can be useful when jquery library is referenced after the page contents. Now the helper produces the jQuery.ready handler with html table definition and jQuery library is not yet referenced.

daanl commented 11 years ago

Its already in there

daanl commented 11 years ago

See renderjavascript and renderhtmlelements

MichaelSL commented 11 years ago

Maybe it would be helpful to have some extensions to write the code into the page. Something like this:

public static class MvcJqGridExtensions
{
    public static HtmlString RenderHtml(this MvcJqGrid.Grid grid)
    {
        return new HtmlString(grid.RenderHtmlElements());
    }

    public static HtmlString RenderJs(this MvcJqGrid.Grid grid, string gridId = null)
    {
        var resStr = grid.RenderJavascript();
        if (gridId != null)
        {
            resStr.Replace("##gridid##", gridId);
        }

        return new HtmlString(resStr);
    }
}