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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dynamic create and selected the Tab after row selected in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

146799 Aug 20,2019 03:08 PM UTC Aug 22,2019 02:48 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: Tabs
Kenneth Tang
Asked On August 20, 2019 03:08 PM UTC

Dear all,

We could create a dynamic tab with grid by using rowselected event. but please advance how could make it be selected and display on the top of the tabs.

the following code which we had


var totalItems = 0;


    function rowSelected(arg) {

        var content = document.getElementById('tab-content').value;

        var ajax = new ej.base.Ajax('/Home/_StaffView?GUID='+ arg.data.EM_GUID, 'GET', true);

        ajax.send().then();

        ajax.onSuccess = function (data) {

            var ctn2 = data;

            // Required tab item object formed by using textbox inputs

            var item = { header: { text: arg.data.EM_NAME }, content: ctn2 };


            totalItems = document.querySelectorAll('#element .e-toolbar-item').length;

            // Item object and the index argument passed into the addTab method to add a new tab

            tabObj.addTab([item], totalItems-1);

        }

    };

var totalItems = 0;


    function rowSelected(arg) {

        var content = document.getElementById('tab-content').value;

        var ajax = new ej.base.Ajax('/Home/_StaffView?GUID='+ arg.data.EM_GUID, 'GET', true);

        ajax.send().then();

        ajax.onSuccess = function (data) {

            var ctn2 = data;

            // Required tab item object formed by using textbox inputs

            var item = { header: { text: arg.data.EM_NAME }, content: ctn2 };


            totalItems = document.querySelectorAll('#element .e-toolbar-item').length;

            // Item object and the index argument passed into the addTab method to add a new tab

            tabObj.addTab([item], totalItems-1);

        }

    };



Thank a lot!

KennethT

Karthigeyan Krishnamurthi [Syncfusion]
Replied On August 22, 2019 02:48 AM UTC

Hi Kenneth, 
 
Syncfusion greetings. 
 
We suspect that your requirement is to focus the dynamically added Tab items and for the same below sample is prepared. 
 
function onRowSelected(args) {  
    var selectedrecords = this.getSelectedRecords() 
    for (var i = 0; i < selectedrecords.length; i++) { 
        var title = selectedrecords[i].Employees; 
        var content = selectedrecords[i].Designation;   
        // Required tab item object formed by using textbox inputs 
        var item = { header: { text: title }, content: ej.base.createElement('pre', { innerHTML: content.replace(/\n/g, '<br>\n') }).outerHTML }; 
 
        totalItems = document.querySelectorAll('#defaultTab .e-toolbar-item').length; 
        tabObj.addTab([item], totalItems); 
        tabObj.selectedItem = totalItems; 
    } 
    tabObj.refresh(); 
} 
 
If we misunderstood your requirement, kindly share the requirement image to proceed further. 
 
Regards, 
Karthi 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon