Removing all items from Kendo UI MVVM ObservableArray - mvvm

What is the recommended method for removing all items from a Kendo UI MVVM ObservableArray?
First, I tried re-initializing the ObservableArray, but that caused problems in my app. Next, I tried setting the length of the ObservableArray to 0, but that also caused problems. Then, I put the pop() method in a while loop. So far, that seems to be working, but I'm wondering if that's the recommended method.

Update 23/01/2016 - patriks (answer below mine) has discovered a .empty() method which appears to be undocumented which does what I have used as an inbuilt method:
console.log(searchResults.empty); //function(){this.splice(0,this.length)}
I would recommend using this approach instead.
Old answer:
Just had to solve this today, I got it working with this:
var searchResults = new kendo.data.ObservableArray(['A', 'B', 'C']);
...
searchResults.splice(0, searchResults.length); //empties array.
Fiddle: http://jsfiddle.net/KyleMuir/wJW6f/

Happened to stumble upon this old thread and just thought I'd add that there is an (undocumented?) empty() method for ObservableArrays that does the splicing for you.
Updated Kyles fiddle: http://jsfiddle.net/wJW6f/2/

Related

initializationListener is null, you will not receive any callbacks - Unity

What kind of error is this? I've looked for a fix but haven't found anything related
https://i.stack.imgur.com/Fk6uY.png
I also encountered the same error.
You need to add the InuityAdsInitializationListener class and the OnInitializationComplete and OnInitializationFailed methods.
The error is occurring because of the absence of those.
Please refer here for more information.
https://docs.unity.com/ads/InitializingTheUnitySDK.html
You need two things. As said above, you need to implement the IUnityAdsInitializationListener interface as well as it's methods.
However, you also need to tell the Advertisement which class implements that interface inside of your Advertisement.Initailize function. If you are upgrading from an old version, you may not notice the new overloaded functions.
Specifically you need to call
Advertisement.Initialize(gameId, testMode, IUnityAdsInitializationListener);
For example:
Advertisement.Initialize(gameId, false, this);
You have to do the Following
For Initilization
Advertisement.Initialize(unityAdsId, true, this);
For Loading
Advertisement.Load(intrPlacementId, this);
For Showing Ads
Advertisement.Show(rewardedPlacementId, this);
So the thing is that you have to add "this" key word in inilization and loading and showing methods
I have solved my issue using above code

How to make copy of array's elements in the dart

Getting wired issue like main array has been changed if changed value of another array. I think issue is about copying same address, not sure but just thinking of it. I have tried from last 3 hours but unable to get rid from it.
Look at below illustration to get better idea.
List<page> _pageList;
List<page> _orderList = [];
_pageList = _apiResponse.result as List<page>;
_orderList.add(_pageList[0].element);
_orderList[0].title = "XYZ"
//--> Here if I change the `_orderList[0].title` then it also change the `title` inside "_pageList"
How can we prevent the changes in main array?
I got same issue in my one of the project. What I have done is, use json to encode and decode object that help you to make copy of the object so that will not be affected to the main List.
After 3rd line of your code, make changes like below
Elements copyObject = Elements.fromJson(_pageList[0].element.toJson());
// First of all you have to convert your object to the Map and and map to original object like above
_orderList.add(copyObject);
Hope that will help you.
You can use a getter function to create a copy of your list and use that instead of
altering your actual list.
example:
List<Page> get orderList{
return [..._orderList];
}
Lists in Dart store references for complex types, so this is intended behaviour.
From your code:
_orderList.add(_pageList[0].element);
_orderList[0] and _pageList[0].element point to the same reference (if they are non-primitive).
There is no general copy() or clone() method in dart, as far as i know. So you need to copy the object yourself, if you want a separate instance. (see this question)

(UE4) Is there a method of getting all actors in camera view?

Like the title says, i want to be able to get all actors that are within the camera view in Unreal Engine 4.
I have thought of two ways i could do this: 1) using a shape trace in the form of a "boxtracebyobject" which works but seems to be glitchy at times and has trouble recognizing multiple overlapping actors. 2) using a "BoxOverlappingActors", though i havent quite figured out how to use it yet.
If anyone knows of a proper method to getting actors in cameria view, my ears are open!
Update
A much better answer has been posted on Unreal Answers by Rama:
Use the AActor::GetLastRenderTime() to find out for each actor when last drawn or UPrimitiveComponent::LastRenderTime for the primitive itself. His answer explains how you can use this.
Original answer:
As you suggested, it seems weird that you would have to do something to do with collision volumes when Unreal must be checking to do culling so I found the following method to query that information:
First we have to create a FSceneView from the camera. This code is taken from the UE Answers question.
APlayerCameraManager* Manager = World->GetFirstPlayerController()->PlayerCameraManager;
ULocalPlayer* LocalPlayer = World->GetFirstLocalPlayerFromController();
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
LocalPlayer->ViewportClient->Viewport,
World->Scene,
LocalPlayer->ViewportClient->EngineShowFlags)
.SetRealtimeUpdate(true));
FVector ViewLocation;
FRotator ViewRotation;
FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport);
Once we've created the view we can iterate through all primitive components (includes meshes) and then we can use the bounds from the SceneProxy of the Static Mesh and the bounds of the view to do our own culling.
for (TObjectIterator<UPrimitiveComponent> ScenePrimitsItr; ScenePrimitsItr; ++ScenePrimitsItr)
{
// Using the Object iterator so we have to skip objects not in the
// relevant world
if (ScenePrimitsItr->GetWorld() == World)
{
FPrimitiveSceneProxy* Proxy = ScenePrimitsItr->SceneProxy;
if (Proxy)
{
bool bIsShown =
SceneView->ViewFrustum.IntersectSphere(Proxy->GetBounds().Origin, Proxy->GetBounds().SphereRadius)||
SceneView->ViewFrustum.IntersectBox(Proxy->GetBounds().Origin, Proxy->GetBounds().BoxExtent);
}
}
}
The frustrum check came from SceneVisibility.cpp in the method FrustumCull This method isn't ideal as a) involves duplicating that check and b) performing the test twice. However, I couldn't find a way to actually query the result. It appears to be stored in a bit array in the FViewInfo. Unfortunately this info is not exposed outside of the renderer module.
You could try this to create an array of actors:
But I don't know if it's good performance wise if there are too many actors of the class you want.

How to load data into Ext.tree.TreePanel (not through ajax)

in example here
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.tree.TreePanel
i can see property dataUrl: 'get-nodes.php',
but how i can change data from inside my code? there is no store property or setSource method
EDIT:
as i found, one of the possibilities is to create my own Ext.tree.TreeLoader that would have setSource method and use it instead of default
maybe there is more variants?
EDIT:
seems there is already a solution for this
http://www.sencha.com/forum/showthread.php?4595-Creating-Ext.tree.TreePanel-from-static-JSON-data-in-one-shot
seems there is already a solution for this
http://www.sencha.com/forum/showthread.php?4595-Creating-Ext.tree.TreePanel-from-static-JSON-data-in-one-shot

Business Logic when Saving in Entity Framework

If I want to perform some action when an entity is saved, I can do something as described here.
However, suppose I retrieve an object from the database. This object has a list of items within it. If I instantiate a new item and add it to this list and then save all changes, the item in the list is not part of the "GetObjectStateEntries".
The problem for my situation, I believe, has been resolved. There appears to be a bug, in my opinion, in the ObjectContext.SaveChanges(SaveOptions) method. Even though this method will call DetectChanges (depending on the saveOptions), the OnSavingChanges method is called FIRST. This, I think, is a problem.
The solution to this is to call ObjectContext.DetectChanges() prior to calling SaveChanges().