ng-grid get column index with row.entity possible? - angularjs

I am able to access the row.entity object for my drag and drop directives using https://github.com/logicbomb/lvlDragDrop/blob/master/script/lvl-drag-drop.js. I get the row.entity with code like this
angular.element(element).scope().$parent.row.entity
With this code I can see the row's data, but what I need is the column. Basically I can drag and drop an ng-grid cell into any other ng-grid cell, I want to know all the data the row has, as well as the specific cell that was drag/dropped.
I have tried $parent.col, but not sure what else to try.

If you want to show column index
cellTemplate: '{{grid.renderContainers.body.visibleColumnCache.indexOf(col)}}'

Try getting the column data from the row entity. It looks like you may be able to do something like 'row.entity[col.index]'. Try inspecting $parent.row.entity to see what else is stored in there.

Related

ExtJS Trying to add records from one grid to another grid allowing duplicates

I have two grids with the same columns. I want to add records from grid 1 to grid 2 and I want to allow duplicates in the second grid. I know stores have an id property to not allow duplicates. I override this using idProperty: 'customId' config in the model. I'm using an autoincremental customId field as the new idProperty. But this doesn't work: I click twice or more times at the select column but nothing happens (it only works the first one). How can I solve this?
I did a fiddle with the example.
when you are adding record to destination Grid's store, instead of adding record, use record.data property to pass pure data object, not a model object.
destinationGrid.getStore().add(record.data);
here is fiddle

Ng-Grid Reference first column

I am using NG-grid to display data in a table. I need to hide certain cells in a row if the 2nd cell in that same row gives back a certain response. I am writing a method that for each cell it will check to see what the value of the 2nd cell in this row is. My problem is I have no idea how to reference the value in that 2nd cell. Is it something like {{row.entity[col.field[1]]}}??? Thanks you
If you have access to the column name, you can use {{row.getProperty(\'columnName\')}}.
You can look at the row templates for an example.

uiGrid switch rows and columns

This is a bit of a general question into the possibilities of ui grid. I have had tremendous success with ui grid thus far. Now I have a use case where I want to switch the rows and columns of the grid.
Basically, I would like the headers to be displayed 'vertically' in the first column and to have the rows become columns.
Is this possible with ui grid?
As far as i know UI-grid doesn't support this. I doubt if you can do that. May be try building ColumnsDef and Data dynamically and pass it to gridOptions. Or else add extra column and this should be the first column where you will pass all the header values. Change the background of the cells to look like header cells. Now add second column where you pass the entire first row values. Hide the original header row completely. see now u got your required grid........ :)

Grid not updating upon change in model in angularjs

Folks,
I am using ng-grid to display a list of items.
I want to give my users ability to rearrange the rows in the list.
i.e move the rows up and down as they please.
Now,
However when I update the grid data in the backend i.e say change the index of a particular row, that row does not automatically change locations in the front-end.
What am i missing here ?
I have created a plunker to describe the problem
http://plnkr.co/edit/s1hrTSqF2zeZo3Btaln0
The grid doesn't use the index of the array to order it, so even if you are changing it, because the data is still there nothing happens.
What you could do is define an order field and update the value then changing the values as shown in this plukr. The order field you can hide it from the grid if required using columnDefs to explicitly defined which column should be shown.
Regards

updating an ng-grid cell

I'm displaying an ng-grid and I would like to change a particular cell's content based on an update. I don't want to make the cell editable. I'm instead popping up a dialog when they click on a Row. When they submit the data, I update the db using ajax, but I don't want to refresh the page. I'd like to update the cell to say something like "Updated". I haven't found anything in documentation or examples that would allow me to modify a particular cell on the fly. Anybody wanna point me in a right direction?
I do something similar with my data. Use a row or cell template to show your dialog using ng-click and pass a reference to the row.entity to your dialog. Then you can just update the data on the row.
I created an example below where I have a cell template that has an event to capture the row, column, and cell data. Then I allow for the user to update the value, and on the button click I update the row with the new value.
Plunkr here:
http://plnkr.co/edit/JQ7mtD?p=preview

Resources