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.
Unfortunately, activation email could not send to your email. Please try again.

PartialView

Thread ID:

Created:

Updated:

Platform:

Replies:

116929 Jul 2,2014 05:13 PM Jul 4,2014 03:22 AM ASP.NET MVC 6
loading
Tags: Grid
Rick Thompson
Asked On July 2, 2014 05:13 PM

VS 2013
Syncfusion MVC: 12.1451.0.49

I View where I do this:

foreach (var lve in Model.Layouts)
{
  <div id="layout_@(ii.ToString())">
  @{
    Html.RenderPartial("Layouts_Grid", (Models.LayoutEntry)lve, new ViewDataDictionary { { "id", ii }, { "data", Model.ExampleData } });
    ii++;
  }
  </div>
}

I have an action to repopulate the div after a cancel or save event. Inside View Layouts_Grid are some ejButtons and an ejGrid and in the save or cancel events I'm simply calling the action to get the html for the partial view. Looking at the return content all looks good, the problem is the ejButtons and the ejGrid don't "redraw" correctly so in my ajax success function I tried gridObj.templateRefresh but get the following error:

Error: ejGrid: methods/properties can be accessed only after plugin creation...

Here is what the ajax success function looks like for reference:

...
success: function (response)
{
$(divID).html(response);
var gridObj = $("#layoutGrid_" + index).ejGrid("instance");
gridObj.templateRefresh();
},
...

any ideas?

Thanks,

Rick

Huntero
Replied On July 3, 2014 06:34 AM

Sounds like a similar problem i had few days ago that i posted here: https://www.syncfusion.com/support/forums/aspnetmvc/grid/116890 

    Try adding the ej.widget.init with the id of the container your updating.

success: function (response)
{
$(divID).html(response);
                                
                                ej.widget.init($("#AjaxUpdateTarget-container"));
}

If that doesn't fix it just wait a bit for an official response :)

Rick Thompson
Replied On July 3, 2014 09:35 AM

Hello Huntero,

I tried what you recommended and it didn't work, as you indicated it may not.

However, if I add

@Html.EJ().ScriptManager()

to the bottom of my partial view (which also exists in _Layouts.cshtml) everything worked. Not sure if there will be any repercussions but for now it looks good.

Thanks,

Rick 

Rick Thompson
Replied On July 3, 2014 09:38 AM

One more thing, I didn't have to do anything special in my ajax success function, this is all I had:

...
success: function (response)
{
  $(divID).html(response);
},
...

All my ej controls rendered correctly simply by having the @Html.EJ().ScriptManager() in my partial view, and there seem to be no "clash" with it also being in _Layouts.cshtml.

Ragavee U S [Syncfusion]
Replied On July 3, 2014 10:41 AM

Hi Rick

 

We have analyzed the issue that you have mentioned. For your convenience, we have created a simple sample with partial view to repopulate the data within the div using the ajax call. The sample can be downloaded from the attachment. Please refer the below code snippet:

 

[In index.cshtml]

<div id="main">

@Html.EJ().Button("click").Text("Render Grid").Render()

@Html.Partial("_partial", this.ViewData)

    </div>

 

<script type="text/javascript">

    $("#click").click(function () {       

        $.ajax

                ({

                    url: "Home/Productpartial",

                    type: 'GET',

                    success: function (data) {                       

                        $("#main").html(data);                       

                    }

                });

    });

</script>

 

[In controller]

        public ActionResult Productpartial()

        {

            var DataSource = new NorthwindDataContext().EmployeeViews.ToList();

            ViewData["datasource"] = DataSource;

            return PartialView("_partial",ViewData);

        }

 

We suggest you to use return PartialView("_partial",ViewData) instead of return View("_partial",ViewData), because the whole html page is bound to the data of the success event of ajax call and the scripts tags are again included within the partial page content. Hence this issue had arosed.

 

Note: While rendering a control in the partial view, we need to specify @Html.EJ().ScriptManager() in the partial view page after the initializing the control. Please refer the below code snippet.

 

[In _partial.cshtml]

@(Html.EJ().Grid< object >("Grid")

        .Datasource((IEnumerable<object>)ViewData["datasource"])

        .AllowSorting()

        .AllowPaging()

        .Render())

@Html.EJ().ScriptManager()

 

Please let us know if you need any further assistance.

 

Regards

Ragavee U S



Attachment: SampleApp_6d67b283.zip

Rick Thompson
Replied On July 3, 2014 11:17 AM

Thanks for the information. I was doing everything as indicated, but I didn't have the @Html.EJ().ScriptManager(). As indicated in one of my earlier replies I added @Html.EJ().ScriptManager() and it began working.

Thanks,

Rick

Ragavee U S [Syncfusion]
Replied On July 4, 2014 03:22 AM

Hi Rick

 

Thanks for the update.

 

We are happy that your issue is resolved.

 

If you have any issues in the future, please get back to us. We will be happy to assist you.

 

Please let us know if you would require any further assistance.

 

Regards

Ragavee U S


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.

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.

;