Ngrx with Angular Formly and Angular Material - javascript

Im using a combination of formly ,ngrx and material. There are few issues that managed to fix and some other on doubt.
Demo is below on stackblitz. :
https://stackblitz.com/edit/new-project-3gxwan?file=src%2Fapp%2Fshared%2Fcomponents%2Fformly-table-generic%2Ftable.ts,src%2Fapp%2Fshared%2Fcomponents%2Fformly-table-generic%2Ftable.html
Im trying to build a filter service and as model have passed an observable. As we filter data of observable change and also model, BUT the view doesnt change. I managed to recall the model and its working but it doesnt look like the most efficent way. especially on big data the view freeze till searching completed.
As on NGRX state is immutable is expected that for every change to be dispatched an action and model to be changed. However the only way to achieve that it was to create my own elements. So in the example if under main.ts comment the following code (my own checkbox element)
{
name: 'checkbox',
component: FormlyFieldCheckbox,
wrappers: [],
},
In table will be implemented tha material checkbox and when we check it will be displayed the read-only error.
Sorting through each columns its not working despite the *matColumnField match with the key name.

Related

VueJs Understanding v-model and v-on:click

I'm currently trying to learn VueJS coming from a jQuery background and I've run into something that I either don't understand or trying to do wrongly. I'm using VueJS and Laravel. I add VueJS to my blade templates.
I have table set up with a few rows of data. In those rows I have a text input field. Each row also contains two icons that allow me to move the row up or down.
When I click on the icon I want to send a axios request telling my database to update the order field. When it returns a success message I want to reload the table with the new order.
After clicking the v-onclick icon and reloading the table into my div with an axios get the v-onclick stops working. Also the v-model binding that I've set up also stops working. When I update a value in a text input it no longer updates the value in the data property.
I've added a jsFiddle to give an idea of what I'm trying to accomplish.
I use axios to get a route that returns the products table view.
```reload : function(){
url = '/products;
axios.get(url).then(response => {
document.getElementById('products').innerHTML = response.data;
});
},```
https://jsfiddle.net/k8Lj4asb/1/
This is not the proper way to update a table in VueJS. By manipulating the DOM directly, you perform changes to the site that Vue doesn't track (and hence doesn't know about), which breaks reactivity.
The proper way to do this would be to store your list in a Vuex-Store and perform the update in there. I recommend reading up on the topic using the excellent documentation provided here: https://vuex.vuejs.org/
I would pass the object of products to javascript, Laravel has a package for this https://github.com/laracasts/PHP-Vars-To-Js-Transformer by Jeffrey Way.
Edit: oh cancel that, it looked from your broken fiddle you were trying to do something different.
In your axios response handler just update a data property for products with the response data. Then loop that property in VUE, no PHP side loop required.
<td v-for="product in products">
<input v-model="product.id" type="text" :name="product.name">
</td>

angular office fabric ui table, get selected items

I am working on an angular app that uses ngOfficeUiFabric for their components.
What I want to do is get the selected items from the existing table component.
http://ngofficeuifabric.com/demos/uifTable/
in the documentation is says this is available with the table.selectedItems property. The problem is that I need this outside of the hierarchy of the table.
Is there a way for me to bind that table property to a variable in my controller?
I am new to both angular and office ui fabric so if I am missing something obvious please excuse me!
regards
There is table.selectedItems property, you can get records form this property

Refreshing Angular view after changing a value

Because the page I am working on is a legacy page with lots of dead/living/zombie code I am unable to paste it whole here. So I am trying to post a digest of my issue with sample code.
I have a page in which data comes from Angular. It is a bunch of products. Each product has an attribute named showProduct that determines it should be shown or not. The showProduct attribute is set to 1 when it is first fetched from the backend. While rendering the html, in each product div I have
ng-show={{product.showProduct}}. The ng-show works correctly the first time when its loaded, all products are shown. If from the backend I set this to 0 for any product, it is hidden.
Once the products are loaded, if the user clicks a button, I need to hide some of those products. This button click handler is in jQuery.
So I do the following:
prod = angular.element($('#product-section')).scope().ProductList;
prod is now an array of products with their attributes. Now I iterate through this array, check for the attribute in question (which I know based on what button was clicked) and based on its value for each product, I set a showProduct attribute to 0.
However this does not update the view, to hide that product. If I console.log the angular.element($('#product-section')).scope().ProductList, I can see that its showProduct has correctly been update from 1 to 0.
I am assuming that there is something I need to do in order to make the productList be "re-parsed" and refreshed in the page. However I am not sure how to do this.
I just needed some conceptual tips on what I might be missing, because I understand that providing "specific" code tip for my situation is difficult.
In a nutshell, once I have updated the angular value externally, how do I tell Angular to reparse the code and refresh the view? Something like how it happens automatically for models when updating data in a textbox...
I tried doing angular.element($('#product-section')).scope().$apply(); but that did not work.
Any pointers are greatly appreciated.
Try this:
$scope.$apply(function() {
angular.element($('#product-section')).scope().ProductList;
});
By doing this, you're telling AngularJS to watch what your enclosed code is doing and update the view accordingly.
Just some consideration: wouldn't you be able to just update the model directly instead of invoking an external code? This approach is always recommended.
Angular uses two way data binding, which works, when you use an Angular-Controller (or Directive, etc), in which you define your model. In your HTTML you use something like this (very crude example):
<div ng-controller="myProductListController>"
<div ng-repeat="(index, product) in productList">
<div>{{ product.name }}</div>
</div>
</div>
productListis in your myProductListController and is available in the scope (your model) of your ng-controller directive.
Now, each time the productList changes in your controller, your view will update automatically.
Scopes (models) are bound to some Angular-Controller (or Directive, ...). So you need to have that, in order to use two-way-binding here.
Hope that helps

Multiple models into one route and filtering for Ember select

I have two models loading into one route (edit page) through the setupController function. This is because the page is using a dynamic segment. Within the edit page, I also have a select dropdown list which is populated via another api ("options" API).
I'm having trouble using the filter to filter through the api and then applying it to the ember select element. When I try and filter, I get an error. I can't seem to filter through the options API.
Here is a jsbin to demonstrate my problem: http://emberjs.jsbin.com/salivo/3/
Performing the async lookup and setting the two lists through the setupController entirely, instead of via computed controller functions, works just fine
http://jsbin.com/pahezivuli/2/edit?html,js,output

EXtjs Grid Filters

I am a new user of Extjs library, I created a grid successfully and it works just fine, now I want to use Ext.grid.GridFilters to add filtering to my grid, however I don't see this class in the Extjs source code files, where I can get the required files?
The community-supported plugin for grid filtering is found in this forum thread.
Filtering is a custom thing you have to implement by yourself. There are a few community add-ons which make it easy, but start by looking at the actual grid STORE instead of the grid panel. The store contains the data and supports filtering. Once the data is filtered, the store will raise it's data changed event and as long as the grid is wired accordingly you will see the filtered recordset in the grid. For more info I'd check out their example pages and read the source there.
As mentioned above: use the filter method in the store.
There is a tutorial covering the subject at http://aboutfrontend.com/2011/01/extjs-grid-filter/
There is proper filter option is provided by ExtJs:
store.filterBy(function(rec, id)) { return (rec.get("RecName") =="FilterRecord");}
After filtering data, filter will always present in stores Filters config. So if we want to remove filters and show all records then just clear applied filters like this:
store.clearFilter();

Categories

Resources