Issue using Same partial view in multiple tabs

I try to load same partial view into multiple tabs, using click -> Ajax calls to controller to return the view and then loading  <div> with returned html.
partial view loads on all tab on click.
I found some info re partial view having same id on all tabs in this case.
How to bind same PT (with Syncfusion grid) to multiple Syncfusion tabs correctly ?
or I have to come up with a way to produce dynamic id for pt on each pt use?

Thank you

1 Reply

PO Prince Oliver Syncfusion Team January 30, 2018 11:22 AM UTC

Hi Marina, 

Thank you for contacting Syncfusion forums. 

Yes, you need to generate dynamic ID’s for the tab item and for the all the control’s in the partial page. We have prepared a sample as per your requirement. Kindly refer to the following code snippet.   

@{Html.EJ().Tab("Tab5").Items(data => 
    { 
    data.Add().ID("GridContent1").Text("Grid Content 1").ContentTemplate(@<div> </div>); 
 
    }).ClientSideEvents(e => e.Create("create")).Render();} 
 
<input type="button" value="Add New TabItem" id="btn" onclick="btnclick();"> 
 
<script> 
    var count = 1; 
    function create(e) 
    { 
        $.ajax({ 
            url: '/Tab/_Grid', 
            type: 'POST' 
 
        }).done(function (result) { 
            $("#GridContent1").html(result); 
        }) 
    } 
    function btnclick() { 
        count++; 
        var tabObj = $("#Tab5").data("ejTab"); 
        tabObj.addItem("#GridContent" + count, "Grid Content" + count); 
        $.ajax({ 
            url: '/Tab/_Grid', 
            type: 'POST' 
 
        }).done(function (result) { 
            result = result.replace(/Grid1/g, "Grid"+ count) 
            $("#GridContent" + count).html(result); 
        }) 
    } 
</script> 
   
In the above code, we have used AJAX post to fetch the data and on the done handler, we have replaced the control’s ID and render them inside the TabItem. Also, used a global flag variable to keep track of the count. 


Regards, 
Prince 


Loader.
Up arrow icon