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. Image for the cookie policy date

Build columns of grid through service in grid

Hi,
I have to bind remote data to grid but columns of the grid should build thought separate API call
i have build columns in using e-create but the columns not creating in that way

Here i have created sample on JS playGround please check,

Sample

http://jsplayground.syncfusion.com/wzbau2zg


4 Replies

JK Jayaprakash Kamaraj Syncfusion Team November 2, 2015 11:27 AM UTC

Hi Gomtesh,

Currently we don’t have support to refresh the columns in angular JS. We have considered
 “Refresh columns in angular JS” as an improvement task and it is estimated to be included in our Vol 3, 2015 Service Pack 2 release which is expected to be roll out at the end of month October, 2015. We have tried to achieve the requirement using column method. In this method, we have added or removed columns in Grid column collections. Please refer to the code example, 

$scope.databound = function () {

                custService.get().then(


                                 function (response) {

                                     var columns = response.data;                                                        var gridObj = $("#Grid").data("ejGrid");

                                     var colField=[];

                               for (var i = 0; i < gridObj.model.columns.length;i++){

                                         colField.push(gridObj.model.columns[i].field)

                                     }

                                     for (var i = 0; i < columns.length; i++)

                                                                 colField.splice(colField.indexOf(columns[i]),1)

gridObj.columns(colField, "remove");

                                 }

                            )
            }


Sample,

http://www.syncfusion.com/downloads/support/forum/120987/ze/ServerOperations1929213928
 
Refer to UG Document for more details, 
http://help.syncfusion.com/js/api/ejgrid#methods:columns

A support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates. 


https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents 


Regards,

Jayaprakash K.



GO Gomtesh November 3, 2015 08:53 AM UTC

Hi Jayaprakash,

gridObj.columns(colField, "remove");

As you given solution for removing columns  but i have used column chooser for that i hvae to only show and hide columns at service call i.e. custService.get().then(

and in column chooser i have to show all columns.



GO Gomtesh replied to Gomtesh Hatgine November 3, 2015 08:56 AM UTC

Hi Jayaprakash,

gridObj.columns(colField, "remove");

As you given solution for removing columns  but i have used column chooser for that i hvae to only show and hide columns at service call i.e. custService.get().then(

and in column chooser i have to show all columns.


For tha i dont want to remove columns if remove columns then in column chooser i will not get all column fields


JK Jayaprakash Kamaraj Syncfusion Team November 4, 2015 10:15 AM UTC

Hi Gomtesh,

We have achieved your requirement using “visible” property in columns, which is used to get or set a value that indicates whether the column is visible or not in Grid. Columns can be returned from the server side. In this columns method, set visible property as false for hide columns. Please refer to the code example and Help document as below,
Code example:

                custService.get().then(


                function (response) {                            

                    var gridObj = $("#Grid").data("ejGrid");

//here i got 'data'  following manner  fields, headetext, alignments and visible

                     gridObj.columns(response.data);

                     $("#Grid").ejGrid("model.showColumnChooser", true);

                                 }

            )

Help document:

Columns : http://help.syncfusion.com/js/api/ejgrid#methods:columns

Visible : http://help.syncfusion.com/js/api/ejgrid#members:columns-visible

sample : http://www.syncfusion.com/downloads/support/forum/120987/ze/ServerOperations-883327696

Regards,

Jayaprakash K.



Loader.
Live Chat Icon For mobile
Up arrow icon