Gomtesh Hatgine
Gomtesh Hatgine

Reputation: 37

Is possible to decide dynamically form columns with alignment, width, format in syncfusion grid using angularjs

I have to do columns in syncfusion grid should dynamically create with all its parameters using syncfusion grid by passing json data contains all information about to form grid

 <div id="Grid" ej-grid e-datasource="data">

in above code all information to form a grid passing through $scope.data = dataforgrid;

Upvotes: 0

Views: 964

Answers (1)

John R
John R

Reputation: 2791

Please refer the following online link for defining columns with alignment, width and format properties for Syncfusion Grid using angularjs.

Online Link: Sample

For dynamically changing the columns along with it's properties as per the given json data source, define the following code snippets in your controller method.

//...

var newColumns = [
                        { field: "OrderID", headerText: "Order ID", width: 75 , textAlign: ej.TextAlign.Right },
                        { field: "CustomerID", headerText: "Customer ID", width: 80 },
                        { field: "EmployeeID", headerText: "Employee ID", width: 75, textAlign: ej.TextAlign.Right },
                        { field: "Freight", width: 75, format: "{0:C}", textAlign: ej.TextAlign.Right },
                        { field: "OrderDate", headerText: "Order Date", width: 80, format: "{0:MM/dd/yyyy}", textAlign: ej.TextAlign.Right },
                        { field: "ShipCity", headerText: "Ship City", width: 110 }
                ];



//...

$scope.columns = newColumns;

//...

Upvotes: 1

Related Questions