This is a migrated thread and some comments may be shown as answers.

Pop-Up Editor & Conditional Display on Initial Values

2 Answers 283 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MelF
Top achievements
Rank 1
MelF asked on 18 Sep 2012, 06:36 PM
I have a custom editor for the pop-up and everything is working fine. However I would like to hide or show a a section depending on a value from the model. However, these model values are always NULL. 

for example Model.QuoteId is always null

@using (Html.BeginForm(Model))
{
    if (Model.QuoteId == null)
    {
        <fieldset id="selector">
foo
        </fieldset>
    }
}


I do get values for this.

            @Html.EditorFor(model => model.Amount)


thank you!

2 Answers, 1 is accepted

Sort by
0
MelF
Top achievements
Rank 1
answered on 25 Sep 2012, 09:35 PM
there's got to be a better way than this, but this is what I'm using.

<script>
    $(document).ready(function() {
        var grid = $("#Grid").data("kendoGrid");
        var item = grid.dataItem(grid.select());

// render the partial view if this is a new item
        if (item == null) {
            $.get('@Url.Action("GetQuoteSelector","Payment", new { id = Model.Id } )', function (data) {
                $('#divQuote').replaceWith(data);
            });
        }
    });
</script>


CONTROLLER

        public ActionResult GetQuoteSelector(int id)
        {
            return PartialView("QuoteSelector");
        }
0
David A.
Top achievements
Rank 1
answered on 25 Sep 2012, 10:22 PM
I used this successfully in my popup using templating:

<div data-template="lastupdated-template" data-bind="source: this"></div>
 
<script id="lastupdated-template" type="text/x-kendo-template">
    # if(CurrentVersion !=null) { #
        #: kendo.toString(CurrentVersion, "n2")#
    # } else { #
       N/A
    # } #
 
    # if(LastUpdated !=null) { #
       <span style="padding-left:5px;"><strong>(#: kendo.toString(LastUpdated, "M/dd/yyyy h:mm tt")#)</strong></span>
    # } #
 
 </script>


Tags
Grid
Asked by
MelF
Top achievements
Rank 1
Answers by
MelF
Top achievements
Rank 1
David A.
Top achievements
Rank 1
Share this question
or