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

Can't bind a grid in a tab within a tab

1 Answer 50 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.
Kevin
Top achievements
Rank 1
Kevin asked on 28 Jul 2011, 02:20 AM
OK.  I am trying to bind a grid using Ajax that is inside a partial view inside a tab within another tab that was dynamically created.  Make sense?

So you have this tabstrip that you can dynamically (programmatically) add tabs too.  Each one of those tabs have a partial view.  In one of those partial views, I have another tabstrip (but this one is static - not dynamic). One of those static tabs has a partial view with a grid.

I can't get that grid to bind using Ajax.

I have included the following code:

  • JobControls.cshtml: The partial view that the dynamic tab loads

Relevant code:

@{Html.Telerik().TabStrip()

        .Name("jobTabstrip")

        .SelectedIndex(0)

        .HtmlAttributes(new { style = "height: 250px; width: 1038px;" })

        .Items(tabs =>

        {    

            tabs.Add().Text("Language Pairs").Selected(true).Content(Html.Partial("LanguagePairs", Model.LanguagePairs).ToHtmlString());   // ß IDEALLY WOUDN’T PASS Model.LanguagePairs, instead bind by Ajax        

            //tabs.Add().Text("Tasks").Selected(true).Content(Html.Partial("Tasks").ToHtmlString());

            //tabs.Add().Text("Purchase Orders").Selected(true).Content(Html.Partial("PurchaseOrders").ToHtmlString());

            //tabs.Add().Text("EQD").Selected(true).Content(Html.Partial("EQD").ToHtmlString());

            //tabs.Add().Text("PM and QA Hours").Selected(true).Content(Html.Partial("PmAndQaHours").ToHtmlString());            

        })

        .Render();  

}

  • LanguagePairs.cshtml: Partial view of the Grid I want to populate
  • JobController.cs: Controller.  Can’t get the Ajax method “_SelectLanguagePairs” to fire.  Instead I populate Model.LanguagePairs in method “ActionResult Edit(int jobID)”.


1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 02 Aug 2011, 09:14 PM
OK.  I resolved this issue.  I didn't have the second tabstrip instantiated as a Telerik tabstrip object that called the 'WriteInitializationScript' method, as well as the javscript .eval() code in the ajax call.  This is required for dynamically built controls (see article written by Telerik MVP John DeVight http://www.aspnetwiki.com/telerik-mvc:jquery-ajax-partial-view-and-telerik-controls)

Once I did this and made sure the grid inside this second tabstrip was create in the same way, it all worked.

Steve
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Share this question
or