We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to implement cascade dropdown list in Inline Editing Template

Thread ID:

Created:

Updated:

Platform:

Replies:

130594 May 19,2017 01:46 PM UTC May 30,2017 10:41 AM UTC ASP.NET MVC 3
loading
Tags: Grid
CLAUDIO RICCARDI
Asked On May 19, 2017 01:46 PM UTC

Hi!

I have encoutered some difficulties in implementing this functionality:

I have the following grid:

@(Html.EJ().Grid<SlimHub.Models.Site>("SitesGrid")
                  .Datasource(ds => ds.Json((IEnumerable<Site>)Model.Sites.ToList()).UpdateURL("../NormalSiteUpdate").InsertURL("../NormalSiteInsert").RemoveURL("../NormalSiteDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
                  //.Datasource(Model.Sites.ToList())
                  .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.InlineFormTemplate).InlineFormTemplateID("#customerInlineFormTemplate"); })
                  .ToolbarSettings(toolbar =>
                  {
                      toolbar.ShowToolbar().ToolbarItems(items =>
                      {
                          items.AddTool(ToolBarItems.Add);
                          items.AddTool(ToolBarItems.Edit);
                          items.AddTool(ToolBarItems.Delete);
                          items.AddTool(ToolBarItems.Update);
                          items.AddTool(ToolBarItems.Cancel);
                      });
                  })
                  .AllowResizing()
                  .AllowTextWrap(true)
                  .DetailsTemplate("#SiteDetailsTemplate")
                  .Columns(col =>
                  {
                      col.Field("SiteId").HeaderText("ID").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(0).Visible(false).Add();
                      col.Field("CustomerId").Width(0).Visible(false).DefaultValue(Model.CustomerId).Add();
                      col.Field("InsertDate").HeaderText("Data Ins.").TextAlign(TextAlign.Center).DefaultValue(DateTime.Now).EditType(EditingType.DateTimePicker).Format("{0:dd/MM/yyyy}").Visible(false).Width(20).Add();
                      col.Field("SiteName").HeaderText("Denominazione").Template("#siteNameTemplate").HeaderTextAlign(TextAlign.Center).Width(30).Visible(true).Add();
                      //col.Field("Address").Width(0).Visible(false).Add();
                  })
                  .ClientSideEvents(eve =>
                  {
                      eve.ActionComplete("siteComplete");
                      eve.ActionBegin("begin");
                  })
                        )

Inside the custom inline form template I want to implement some cascade dropdown lists to select REGION --> PROVINCE --> CITY --> ZIP CODE
The data sourse of each dropdownlist is an ajax call triggered when the value of the dropdown changes.

<script id="customerInlineFormTemplate" type="text/template">
    <div class="Row">
        <div class="SubHeaderColumn">Dettagli Sito Operativo</div>
        <div class="siteGroup">
            <table class="SiteTable" cellpadding="2">
                <colgroup>
                    <col width="10%">
                    <col width="90%">
                </colgroup>
                <tbody>
                    <tr>
                        <td>Regione</td>
                        <td class="siteData">
                            <select id="regionList">
                                //OPTION VALUES MUST BE DYNAMICALLY LOADED...
                            </select>
                       </td>
                    </tr>
                    <tr>
                        <td>Provincia</td>
                        <td class="siteData">
                            <select id="provinceList">
                                //OPTION VALUES MUST BE DYNAMICALLY LOADED AFTER AJAX CALL AND DEPEND ON THE CHIOCE OF regionList
                            </select>
                       </td>
                    </tr>
                    <tr>
                        <td>Città</td>
                        <td class="siteData">
                            <select id="cityList">
                                //OPTION VALUES MUST BE DYNAMICALLY LOADED AFTER AJAX CALL AND DEPEND ON THE CHIOCE OF provinceList
                            </select>
                       </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

Each dropdownlist should have a JsRender template but it must be inside the form template...I can't solve this problem? Can you help me?

Thanks. 

Claudio

Venkatesh Ayothi Raman [Syncfusion]
Replied On May 22, 2017 11:20 AM UTC

Hi Claudio, 

Thanks for contacting Syncfusion support. 

We have already discussed about the topic “How to render cascading dropdown while editing” in the below KB document,

https://www.syncfusion.com/kb/5445/how-to-render-cascading-dropdown-while-editing

Refer to the below KB link for “how to change the selecteditem of one column dropdown based on the selection of another column”.

https://www.syncfusion.com/kb/5444/how-to-change-the-selecteditem-of-one-column-dropdown-based-on-the-selection-of-another-column 
 
Please let us know if you have any further assistance on this. 

Regards, 
Venkatesh Ayothiraman. 


CLAUDIO RICCARDI
Replied On May 29, 2017 01:27 PM UTC

Hi,
the topic How to render cascading dropdown while editing” refers to grid editing in inline mode. If I don't mistake, datasource reload of each dropdown list is triggered by ActionComplete event method.
How about inline editing with custom template? Is it the same as inline normal edting?

Can you provide a sample with two cascade dropdown lists in a custom template?

Thanks

Venkatesh Ayothi Raman [Syncfusion]
Replied On May 30, 2017 10:41 AM UTC

Hi Claudio, 

Thanks for the update. 

We have created a Grid sample with UrlAdaptor as well as Inlineform template. We have used actionComplete event and change event for cascading dropdown. ActionComplete event triggers every complete action in grid. Please refer to the following code example, help documentation and sample. 
Code example: 
 
@(Html.EJ().Grid<object>("FlatGrid") 
                        .Datasource(ds => ds.URL(Url.Action("/DataSource")).UpdateURL(Url.Action("/Update")).InsertURL(Url.Action("/Insert")).RemoveURL(Url.Action("/Delete")).Adaptor(AdaptorType.UrlAdaptor)) 
        .AllowScrolling() 
         .AllowPaging()    /*Paging Enabled*/ 
                 .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.InlineFormTemplate).InlineFormTemplateID("#template"); }) 
              . . . 
        .Columns(col => 
        { 
.  .  . 
        }).ClientSideEvents(eve=>eve.ActionComplete("complete"))) 
 
@template 
<script type="text/template" id="template"> 
    <b>Order Details</b> 
    
        
            <table cellspacing="10"> 
                <tr> 
                    <td style="text-align: right;"> 
                        Order ID 
                    </td> 
                    <td style="text-align: left"> 
                        <input id="OrderID" name="OrderID" value="{{: OrderID}}" disabled="disabled" class="e-field e-ejinputtext valid e-disable" 
                               style="text-align: right; width: 116px; height: 28px" /> 
                    </td> 
                   
                </tr> 
                <tr> 
                    <td style="text-align: right;"> 
                        Customer ID 
                    </td> 
                    <td style="text-align: left"> 
                        <span class="txt">Select Group</span> 
                        <input id="CustomerID" type="text" /> 
                    </td> 
                    </tr> 
                <tr> 
                    <td style="text-align: right;"> 
                        Ship City 
                    </td> 
                    <td style="text-align: left"> 
                        <span class="txt">Select Country</span> 
                        <input id="ShipCity" type="text" /> 
                    </td> 
                    </tr> 
                    
            </table> 
        </div> 
        </div> 
</script> 
<script type="text/javascript"> 
        function complete(args) { 
            if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "inlineformtemplate") { 
                
                           . . . 
                //first level child 
 
                $('#CustomerID').ejDropDownList({ 
                    dataSource: groups, 
                    fields: { value: "parentId", text: "text" }, 
                    cascadeTo: 'ShipCity', 
                    change: "onChange", 
                    width: "100%" 
                }); 
                $('#ShipCity').ejDropDownList({ 
                    dataSource: countries, 
                   // enabled: false, 
                    width: "100%" 
                }); 
                if (args.requestType == "beginedit") { 
                    $("#OrderID").attr("disabled", "disabled"); 
                } 
            } 
        } 
        function onChange() { 
            var ctry = $('#ShipCity').data("ejDropDownList"); 
            ctry.element.val(""); 
        } 
 
</script> 

Note: For demonstration purpose, we have rendered the cascade Dropdown list with local data source. If you want, you can also use the remote data source for cascade Dropdown list like in Knowledge base documentation as we have already provided in previous response. 
Help documentation:  



Regards, 
Venkatesh Ayothiraman. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;