AngularJs filter on ngrepeat does not work after routing away and routing back - angularjs-ng-repeat

So I have a filter on an ng-repeat, and it successfully filters based on a property on the model that is a boolean value. This boolean value gets changed when the user clicks on a red icon that removes the selected item in the list. Clicking the red icon sets individual items property to false and the item gets removed from the list by using the filter on the ng-repeat. This changes the data object, so when we navigate away and navigate back, the value is still false but the filter of the ng-repeat stops working for the item that was previously removed. What's weird is that if i click the icon again, it does not remove the already removed item, but i can click on another item on the list to remove it and it will be removed until i navigate away and come back again. When i save and persist, i still have to refresh the page in order to see the removed item filtered.
<div class="note-attachment" ng-repeat="item in $ctrl.list | filter: {'isRemoved': '!true'}">
<div>{{item.name}}</div>
<imp-circle size="xsmall"
color="#F4BABC"
is-plus="false"
hover-color="#e73302"
ng-click="$ctrl.detachItem(item )">
</imp-circle>
</div>

Related

Disallow selecting the empty element of a pop-up menu (a.k.a. drop-down list) such as NativeSelect in Vaadin 8

The pop-up menu widget NativeSelect in Vaadin 8 displays a list of the possible items along with an empty slot at top, presumably to indicate “no item yet chosen”.
How can I disable that empty slot, forbid empty selection?
In preparing the layout, I will set one of the items as chosen by default. The user then is required to always choose one. I want to forbid the no-item-selected case.
To remove that empty item from the dropdown, call NativeSelect::setEmptySelectionAllowed:
nativeSelect.setEmptySelectionAllowed(false);

Kendo ListView and MVVM 'edit template' cancel button resets bound data to initial state

I have a Kendo ListView bound to an Observable object and all is working well.
I'm able to:
Add items to the list
Edit existing items by using the edit template below
Delete items
One oddity though is when I switch an item to edit view and click Cancel it resets all data back to the original data. So if I started with one item with say name and amount fields, I edit the item and change the amount, then add two more items to the list all is well. But then I click edit on any of the items and immediately click cancel, from here it removes all the additional items I added and resets the data for the first item back to what it was at the beginning.
Why would the cancel action do that?
This dojo snippet shows the exact problem I'm having: http://dojo.telerik.com/IKowo
Kendo version 2016.3.1118
EDIT:
One further development, I found a forum post on Telerik stating that you have to have an ID column and a schema:model:id setup otherwise things won't work as expected.
I've updated the dojo snippet as follows: http://dojo.telerik.com/IKowo/2
Since adding the ID to the mix it looks like the amounts aren't being affected by the cancel button but the newly added items still get removed.
Follow the example provided here by telerik
//Binding Listview to local data array & Perform CRUD
http://dojo.telerik.com/eWih/2
The Only Requirement for the cancel event not deleting the new Items is:
The id field should be kept 0 when adding the new item to the datasource
It should be incremented / Updated in the datasource transport.create event (REQUIRED)
happy coding!

RadComboBox: click handlers lost after scrolling when using a client item template with load on demand

I'm using a RadComboBox in the load on demand (lazy) mode with a web service.
I'm using a client side item template of this form: <input type='checkbox' id='cb_#= Value #'/><span>#= Text #</span> (adding a checkbox before each item's text)
In the itemDataBound client side handler for this RadComboBox I'm retrieving the particular item's DOM element and the nested checkbox'es DOM element and adding a click handler function for each of them (using jquery's $(element).click(function() {})).
The click handler functions work fine until I scroll the items out of view and then scroll back, after that the click handlers are not called anymore (the checkbox selection is also lost).
I suppose this is because the DOM elements representing the items get re-created as they are scrolled in and out of view. But the itemDataBound event is raised only once and is not raised again when an item is scrolled back in view.
The only workaround I can think of is to use the onclick attribute in the HTML and reference a global function from there, but this is ugly.
Is there a nicer solution for this then using the onclick attribute?
What it does actually it appends to innerHtml of the list element, but this is effectively re-moving and re-adding every node under the list element.
I worked around this by assigning my click hander and doing the databiding in the itemsRequested client side handler, iterating over the entire list of items obtained with the get_items() method of the RadCombobBox client side object.
itemsRequested is called every time after new items are added to the list and therefore every time after the DOM is re-created.

<rich:select> does not show all items in search mode

I am using rich:select component in my xhtml page
My requirements are :
1) rich:select should be searchable.
2) But should show all elements in the list when clicking the down arrow, irrespective of the search string present.
For making component searchable, I set enableManualInput=true. But,when I search and select some value, and later click on the down arrow (the dropdown expand) it does not show all items in the Dropdown list, but shows only the item currently selected. What happens is, the value of the currently selected item is set as the search prefix.
I need to manually remove all characters on the search field and start searching again.
Is there a workaround for this? Where I want a dropdown of list and also should be able to search through the list. If this component does not support this functionality, is there another alternative component?
I use richfaces 4 and JSF 2.0
Thanks.
You can have the value deleted each time the list is shown (i.e. when you click the input field or the button):
<rich:select id="select" value="#{bean.selectValue}" enableManualInput="true"
onlistshow="#{rich:component('select')}.setValue('')">
It is a bug in RichFaces:
https://issues.jboss.org/browse/RF-11088
It is planned to be fixed in 4.5.0, meanwhile you can take a fix from the pull request:
https://github.com/richfaces4/components/commit/79657a54c90e99bfa1fb5f42eab8bf6f29fc9091

jgGrid Search Dropdown Not Changing

This may be a followup to this question Possible to make jqGrid Search Box Stay on Page? - Or it may be unrelated because clicking the search button manually shows the same behavior.
We have a dynamically generated grid that is created by a) making an ajax request to get the grid columns based on a report id and then b) setting up the grid model and fetching the data. When the page loads initially, we pass in a starting report id, but there is a dropdown box on the page that lets the user change reports.
When the dropdown changes, I unload any existing grid, make the ajax request to get the columns, set up the grid model, and then get the data. The columns change, the data changes, and everything looks correct - except the search columns do not change in the search dropdown.
If I close the search box and reopen it, it still has the old search columns. Likewise, if I click the reset button or reload the entire grid.
I found it after a bit more poking around. I needed to set the recreateFilter option to true
prmSearch = {recreateFilter:true,multipleSearch:true,overlay:false,sopt:['cn','eq','ne','lt','le','gt','ge','in','ni','nc']};

Resources