Jeff Finn February 2016

In .Net MVCGrid I'm unable to pass additional query options using client side bindings

Hi I have a grid that I need to send values to the RetrieveDataMethod. I am using 2 drop down menus like filters but because the menus don't relate directly to the columns in my grid I can't use the filter option.

I really like the Idea of using the client side binding because it is clean and avoids me needing to write any jquery.

The code for my grid is

public static MVCGridBuilder<Batch> BuildGrid(GridDefaults gridDefaults, ColumnDefaults columnDefaults)
    {
        return new MVCGridBuilder<Batch>(gridDefaults, columnDefaults)
            .AddColumns(cols =>
            {
                cols.Add("BatchId")
                    .WithHeaderText("Batch Id")
                    .WithValueExpression(p => p.BatchId.Trim());
                cols.Add("PartNumber").WithHeaderText("Part Number")
                    .WithValueExpression(p => p.PartNumber.Trim());
                cols.Add("AdjustedQty")
                    .WithHtmlEncoding(false)
                    .WithHeaderText("Adjusted Qty")
                    .WithValueExpression((p, c) => c.UrlHelper.Action("AdjustBatchQuantity", "Batch"))
                    .WithValueTemplate("<a href='#' id='AdjustedQty' style='display: inline;' data-type='text' data-pk='{Model.BatchId}' data-url='AdjustBatchQuantity' data-title='Adjust Quantity' class='editable editable-click' >{Model.AdjustedQty}</a>");
                cols.Add("UpdateDate")
                    .WithHeaderText("Update Date")
                    .WithValueExpression(p => p.UpdateDate.ToShortDateString());
            })
            .WithAdditionalQueryOptionNames("FamilyId", "ColorId")
            .WithAdditionalSetting("RenderLoadingDiv", true)
            .WithDefaultSortColumn("UpdateDate")
            .WithDefaultSortDirection(SortDirection.Dsc)
            .WithFiltering(true)
            .WithRetrieveDataMethod(context =>
            {
                var options = context.Que        

Answers


Jeff Finn February 2016

My bad, I had removed

@Scripts.Render("~/MVCGridHandler.axd/script.js")

and placed it in my bundle config, but it didn't seem to work there.

Post Status

Asked in February 2016
Viewed 2,517 times
Voted 12
Answered 1 times

Search




Leave an answer