最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to apply field on cell Template using ng-grid - Stack Overflow

programmeradmin6浏览0评论

i am using ng-grid so in my case for every row i have edit n delete option for a single row data so user can edit and update sp my question how can i pass field in cell template currently my code is that but i am not getting _id as field in function that i used in template for ng-click. _id is basically field for every unique Here is output you can see in image.

second thing how to shrink last column of cell template .

.png

StoresController.js

  $scope.stores = [

            {
                "_id" : "1s445ggfg",
                "name" : "kj",
                "address1" : "sdf",
                "address2" : "sdf",
                "latitude" : "12",
                "longitude" : "12"
            },
            {
                "_id" : "2s45ggfg",
                "name" : "kddsj",
                "address1" : "sdsfdf",
                "address2" : "ssdfdf",
                "latitude" : "23",
                "longitude" : "23"
            }

        ];


        $scope.gridOptions = {
            data: 'stores',
            jqueryUITheme: true,
            columnDefs:
                [
                    {field:'name', displayName:'Name'},
                    {field:'address1', displayName:'Address 1'},
                    {field:'address2', displayName:'Address 2'},
                    {field:'latitude', displayName:'Latitude'},
                    {field:'longitude', displayName:'Longitude'},
                    {field:'', displayName:'', cellTemplate: '<a ng-click="openStoreModal(_id)" id="edit"  data-toggle="tooltip"><i class="fa fa-pencil fa-fw colorInfo" ></i></a><a ng-click="deleteStore(_id)"  id="delete"  data-toggle="tooltip"><i class="icon-trash"></i></a>'}

                ]
        };

i am using ng-grid so in my case for every row i have edit n delete option for a single row data so user can edit and update sp my question how can i pass field in cell template currently my code is that but i am not getting _id as field in function that i used in template for ng-click. _id is basically field for every unique Here is output you can see in image.

second thing how to shrink last column of cell template .

https://i.sstatic/yneQL.png

StoresController.js

  $scope.stores = [

            {
                "_id" : "1s445ggfg",
                "name" : "kj",
                "address1" : "sdf",
                "address2" : "sdf",
                "latitude" : "12",
                "longitude" : "12"
            },
            {
                "_id" : "2s45ggfg",
                "name" : "kddsj",
                "address1" : "sdsfdf",
                "address2" : "ssdfdf",
                "latitude" : "23",
                "longitude" : "23"
            }

        ];


        $scope.gridOptions = {
            data: 'stores',
            jqueryUITheme: true,
            columnDefs:
                [
                    {field:'name', displayName:'Name'},
                    {field:'address1', displayName:'Address 1'},
                    {field:'address2', displayName:'Address 2'},
                    {field:'latitude', displayName:'Latitude'},
                    {field:'longitude', displayName:'Longitude'},
                    {field:'', displayName:'', cellTemplate: '<a ng-click="openStoreModal(_id)" id="edit"  data-toggle="tooltip"><i class="fa fa-pencil fa-fw colorInfo" ></i></a><a ng-click="deleteStore(_id)"  id="delete"  data-toggle="tooltip"><i class="icon-trash"></i></a>'}

                ]
        };
Share Improve this question asked Nov 27, 2013 at 15:39 WajihurrehmanWajihurrehman 5673 gold badges15 silver badges29 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Change ng-click="deleteStore(_id)" to ng-click="deleteStore(row.getProperty('_id')) or ng-click="deleteStore(row.entity._id)"

And for the size of the last column (100px in this example)…

{field:'', displayName:'', cellTemplate: editDeleteCellTemplate, maxWidth: 100 }

@bob ,

There is a Question that covers some aspects that is : ng-grid headerRowTemplate

and You can have Reference for Templating here that might be helpful as well.

发布评论

评论列表(0)

  1. 暂无评论