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

Rendering Grid in Partial View Gets UnCaught Exception Sequence Contains No Matching Element

1 Answer 53 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.
Greg Roberts
Top achievements
Rank 1
Greg Roberts asked on 31 Oct 2011, 08:53 AM
When trying to render the grid in a partial view via an ajax request it appears to always fail...
The culprit is this check for the first script being telerik.common, which it never will be, it
will be an asset with an encrypted name.  This should be fixed...

if
(IsSelfInitialized)
           {
               writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
               writer.RenderBeginTag(HtmlTextWriterTag.Script);
 
               if (ViewContext.HttpContext.Request.IsAjaxRequest())
               {
                   var registrar = ScriptRegistrar.Current;
 
                   registrar.ScriptableComponents.Clear();
                   registrar.ScriptableComponents.Add(this);
 
                   try
                   {
                       var dependencies = registrar.CollectScriptFiles();
                       var common = dependencies.First(file => file.Contains("telerik.common"));
                       var buffer = new StringWriter();
                       WriteInitializationScript(buffer);
 
                       var initializationScript = "jQuery.telerik.load({0},function(){{ {1} }});".FormatWith(new JavaScriptSerializer().Serialize(dependencies),
                           buffer.ToString());
 
                       writer.WriteLine("if(!jQuery.telerik){");
                       writer.WriteLine("jQuery.ajax({");
                       writer.WriteLine("url:\"{0}\",".FormatWith(common));
                       writer.WriteLine("dataType:\"script\",");
                       writer.WriteLine("cache:false,");
                       writer.WriteLine("success:function(){");
                       writer.WriteLine(initializationScript);
                       writer.WriteLine("}});}else{");
                       writer.WriteLine(initializationScript);
                       writer.WriteLine("}");
                   }
                   catch (FileNotFoundException)
                   {
                       WriteInitializationScript(writer);
                   }
               }
               else
               {
                   WriteInitializationScript(writer);
               }
               writer.RenderEndTag();
           }

1 Answer, 1 is accepted

Sort by
0
Greg Roberts
Top achievements
Rank 1
answered on 31 Oct 2011, 08:56 AM
This code was from ViewComponentBase in the  protected virtual void WriteHtml(HtmlTextWriter writer) method
        {
Tags
Grid
Asked by
Greg Roberts
Top achievements
Rank 1
Answers by
Greg Roberts
Top achievements
Rank 1
Share this question
or