$scope.gridOptions.api.SelectIndex doesn't work with datasource - angularjs

I'm using the server side pagination and filtering example with angularjs.
On loading the data in grid, I would like to programmatically set the first row.
However below method does not work if the grid data has been set using data source.
$scope.gridOptions.api.selectIndex
doesn't work with datasource.
It only works after using the $scope.gridOptions.api.setDataSource
I've also opened an issue in github. Below is the link:
https://github.com/ceolter/ag-grid/issues/601
Please help in resolving this issue.

This is to be expected.
The datasource is the object that will provide your server's data.
As long the datasource is not loaded and did not load the 1st datas you can't use selectIndex method since there is nothing to select.
As a workaround i add myself a custom option in gridOptions where you can provide what you want to select at the 1st loading and select them once my data are loaded the 1st time in my datasource. I add another callback to be able to compare datas and another when the data is not found.
If you want something simplier you can pass to your datasource a promise that will be resolved once the 1st data get loaded (resolve it after call params.successCallback(data) !)
Note : the callback params.successCallback(data) to send the new data to the grid from the datasource must be called before using selectIndex whatever the solution you use.

Related

Ext js Pivot Grid Store wrong type

I have a Ext JS (Version 7.3.1) pivot grid like this fiddle:
https://fiddle.sencha.com/#view/editor&fiddle/3col
When i click on Test it will output the grid store type. In this case it outputs "memory" but it's an ajax store, so (i guess) cause of this i can't reload with a simple store.load().
What do i need to do to request pivot grid store ajax again?
I already tried switching store. I switched matrix to remote, I tried with direct proxy too. But everytime it will output memory store. So i can't reload
I never used a pivotgrid, but as far as I can see the pivotgrid itself creates an arraystore during initialization, which contains then probably the calculated data. If you want to access your store in the fiddle - which is defined in the matrix config - you could simply access the matrix and execute here for example the reload function of your store.
Analogous to your code in the fiddle it would look like this:
Ext.getCmp('pivot_grid').getMatrix().store.reload()
// console.log(Ext.getCmp('pivot_grid').getMatrix().store.getProxy().type)
// --> ajax

ExtJS synchronize record between clients

I'm trying to do something fun: I'd like to send the record changes from one client to another and have the second client updated to show these changes. Basically collaborative viewing. The second client is disabled from making changes, he can only watch.
Simple fields like strings, numbers, checkboxes, etc. are easy, that worked right away.
The references are the problem. If I have a combo that uses another model as it's source, I am unable to update it on the second client.
I tried setting just the id, then the entire referenced object, I tried various set options, but simply no dice.
The record does change, I see that the data is updated, I was even able to manually modify the _ reference attributes, but the UI keeps showing the old values for those fields.
Is there a way to send the record from one client to another and have the other client just take over all values and display them in the UI? (it would be better to send just the changes, but I'd be very happy if I could get it to work with the entire record)
EDIT: I'm using SailsJS with socket.io, so the p2p connection is not the issue.
I'm getting the data like this:
var data = record.getData(true);
broadcastRecord(data);
And on the other side I tried:
record.set(data);
A code example for the receiving side would be appreciated, if anyone has an ide how to solve this...
I think your problem is related to associations and comboboxes.
Let's say you have a model User with a field group that references model Group, and that you have a User form with a Group combobox.
In the receiver client, you are probably getting only the group id. record.set(data) updates the bound combobox calling setValue(groupId).
This setValue will try to find the corresponding record inside its store, but it won't ask server-side for that record. Instead, it will create a new record with the passed id (showing an empty combobox).
If possibile, you can set remoteFilter:false to the store and queryMode:'local' on the combobox and preload all the data from that store.
Otherwise, I think you'll have to override the combobox setValue method to get the record remotely.

How can I bind a directive to a column cell in angular-ui-grid?

First, this is what I'm trying to do: I am using ngResource to grab an array of data from an API and setting the ui-grid's data to the array. One of the columns is an ID that has no meaning to the user. I would like to use another API to look up the meaning of that ID and get the human-friendly result of that. Before using ui-grid, I was simply using a directive that took that ID and set the element's text as the return result from the secondary API.
I know that it's possible to bind a column dynamically to data in that row's object, having looked at: http://ui-grid.info/docs/#/tutorial/106_binding, but it appears that this is limited to binding to the data in $scope or in the grid's data (such as in the example). I also see that there is a cellClass options method which allows conditional setting of the cell's class. However, I do not see any good options for intercepting the element in the cell and replacing it with a result of my choosing.
I am wondering what the best way to do this is. I've tried using ngResource's transformResponse but the array is too large to make a blocking event. As well, I've tried to inject the html for the directive into the field's return function, i.e. field: transformToHtml() but only the raw string shows, not the rendered html.

Reloading an Ext.data.Store model?

I'm trying to fix some issue with an ExtJs website but not sure how to proceed. Basically, I have a form that loads an Ext.data.Store model. For new models, the model object initially doesn't have an ID. Once it's saved an ID is assigned to it by the webservice.
The problem is that this Ext.data.Store model is not being reloaded after saving, so it stays without an ID, which causes some problems later on.
So is there any way to force ExtJs to reload the store model after saving? I checked the documentation of Ext.data.Store but cannot see any "reload()" or "refresh()" method. Any suggestion?
You don't need to do anything special. ExtJs has a logic to replace models with phantom flag with the new copies received from the store after update procedure. Chec couple things:
Make sure you have correctly specified idProperty in the model. This is how ExtJs will detect whether record is new or not.
Make sure your store returns properly new/updated records in the response message.
Make sure your data reader properly parses these records in the response message.

Ext JS ComboBox Dynamic Behaviour

I am trying to load/show completely different set of values in a combobox(this one resides as a editor within an EditorGridPanel) based on the valueField of another combobox(this one resides outside the grid in top bar). I have already seen a tutorial(http://www.extjs.com/learn/Tutorial%3ALinked%5FCombos%5FTutorial%5Ffor%5FExt%5F2) wherein ALL the values for the secondary object are stored locally and then filtered however, I have already created a link which will supply me with json data based on the valuefield, so I would like to use this url to keep the code efficient.
I have also tried to refresh the datastore but its simply not being reflected on the combobox.
Please advise
Thanks
Found the solution, loading values from a url is straightforward.. if you want to manipulate the query(like I wanted), you would have to strip url off the dynamic parameters and assign them to baseParams of the store and then call store.load()
It worked for me!!

Resources