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

[Solved] Grid edit popup data binding

0 Answers 27 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Keir
Top achievements
Rank 1
Keir asked on 17 Aug 2011, 05:18 PM
Hi Everyone,

I'm sure there is a simple way to address this but i'm pretty stumped on how to fix it.

I have 2 drop down menus and the 2nd one needs to dynamically load based on the data of the previous drop down but on edit needs to default to the record currently saved.  The first one loads off ViewData and works fine but where im struggling is the 2nd.  On insert it is fine as nothing should be loaded until onopen is fired as it's a new record but on an edit i want to load the drop down values and display the correct selected list item so they don't need to pick it over each time they want to change something on the form.  I've tried triggering a javascript function to load based on the record id but at the time the js fires the id has not been bound and shows as 0.

Is there a way to capture when everything has loaded so i can read correct id from the model and pass it back during the ondatabinding?  Or does anyone have a suggestion on a better way to address handle this situation? 

Here's the editor form that pop-ups:
<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="editor-label" style="text-align: right;">*<%= Html.LabelFor(m => m.Company) %></td>
        <td class="editor-field">
            <%= Html.Telerik().DropDownList()
                    .Name("Company")
                    .BindTo(new SelectList((List<SDLCWeb.Models.Client>)ViewData["CompanyList"], "Company", "Company", Model.Company))
                    .ClientEvents(events => events
                        .OnChange("Custom_ClientProductLoad"))
            %>
        </td>
    </tr>
    <tr>
        <td class="editor-label" style="text-align: right;">*<%= Html.LabelFor(m => m.Product) %></td>
        <td class="editor-field">
            <%= Html.Telerik().DropDownList()
                    .Name("Product")
                    .Items(i => i.Add().Selected(true).Text(Model.Product).Value(Model.Product))
                    .DataBinding(databinding => databinding.Ajax().Select("_GetProducts", "Custom"))
                    .ClientEvents(events => events
                        .OnDataBinding("Custom_ProductDataBinding"))
            %>
        </td>
    </tr>
    <tr>
        <td class="editor-label" style="text-align: right;">*<%= Html.LabelFor(m => m.FeatureCode) %></td>
        <td class="editor-field"><%= Html.EditorFor(m => m.FeatureCode) %></td>
    </tr>
</table>
Tags
Grid
Asked by
Keir
Top achievements
Rank 1
Share this question
or