ember persistantly save sorted model - sorting

I am using this drag and drop addon for ember: ember-drag-drop
So far so good, this works as expected.
I copied the controller- and template code from the demo (ember-data) and adapted it to my model. In my template the records of my model are sorted with drag and drop and are displayed in another list on this site correctly (is updating at the same time as the drag and drop list).
Now, what should I do to permanently save my sorted records ?
Somehow this model must have changed, otherwise the other list would not recognise this or am I wrong ?
Maybe anyone who used this addon came across this, too.
Normally, my records are stored in local storage. For that, I use the ember-local-storage-adapter.
I tried the following:
My model is called buttons. Inside the model there are several records.
const store = this.get('store');
store.findAll('buttons').then(function(sorted){
console.log(sorted);
sorted.save();
});
It seems that with this I only get the old model from the local storage but actually I need the most recent model that lives somewhere on the site.
I hope you understand, what I am struggeling with my mind is running out with all these model stuff.
Thanks for any help and suggestions!

Related

In VS2013 is there an easy way to update attributes in your model?

I'm using VS2013 in a MVC 5 app. Created EF6 model using the database first approach which yielded the model as expected. Subsequently I will make changes in the database objects (tables, views, stored procs). When I go into the model to update it, the visible model will get updated. Looking at the Model Browser, I have to manually clean up the artifacts that no longer exist. Am I missing something in my procedure?
When you right click and update the model from the database, it will typically add new pieces automatically, but in my experience it doesn't automatically remove pieces that are no longer there, so you'll need to watch for those and delete them manually.
On the plus side, if you had any special customizations around a field (e.g. enum types), and the field gets renamed, this gives you a chance to compare the two configurations and make sure they line up before you delete the old field from your model.

Joomla component multiple views

I've read up and done the tutorials for Joomla 3. Here is my problem:
My requirement is more complex than the HelloWorld one. I have multiple tables, on the admin side, to maintain (entries - add, update and delete). Thus it means multiple controllers, views and models (one for each database table)
To explain:
Lets say I have 2 tables in the database; shop and area. The default view is for shop. I've created MVCs called shop and shops - working. Then I created MVCs called area and areas. The areas one works to show a list of the areas in the DB.
The area view works (display the right form, but no data) but there is something wrong with the model; when I look at MyCompViewArea Object's item member, item, it still have the array for shop.
I'm stuck, can you point me to a comprehensive tutorial that covers this?
Ok, silly me!
One gets blind to one's code. I've kept on hunting for the problem and because of another question ask (Fatal error: Call to a member function getKeyName()) I took a closer look at my table class and found that the class name was wrong. It was MyCompTableMyComp instead of MyCompTableArea

Core data, bindings, NSArrayController and table views - how to generate a view of a core data context

I have a working system that lets me build a database containing instances of various entities , all linked together nicely.
Before I knew I would care, I came across a tutorial on using Core Data and bindings, and it went through a complete case where you get a table showing all the entities of some type with a column for each property. It showed both the UI side and the Data model side - not that I need the data model part at this point. Now, darned if I can find it. This is one of those things that is supposed to be easy, and requires virtually no code, but getting exactly the right connections in UIBuilder is not going to happen if I can't find instructions.
Also, I thought I came across an example of something like a query editor where the user could select which properties to sort on, which to match on, etc. Did I imagine that?
Anyone out there know where I can find such?
Sure, you can do this without code:
Add an array controller to your nib.
Bind or connect an outlet for its managed object context
Set the array controller to Entity mode, fill in the entity name, and select Prepares Content.
Bind your table view columns to array controller's arranged objects, and fill in the key name for the model key.
Regarding the query editor, open up the model, and on the Editor menu click Add Fetch Request.
I found at least a partial answer to the query editor question, in this apple tutorial. Not sure how far it will get me, as I prefer to write code where possible, since then I can leave a trail of comments.

optimizing ajax based search

I am doing a ajax based search which suggests the values from the database tables as the user inputs fields in the search box. It does work but its really very slow, takes more than 10 seconds minimum for any suggestions to load. how do I optimize this to make it fast..
Like Index it/save it in cache/crawl?
Right now autoSearch() js function is fired which retrieves data from the related table to load the suggestions. how do I make this faster?
I dont know if this will make a difference but I am using grails/groovy for application development.
Thanks
Priyank
Have you added an index to any searched fields (or checked in the database to make sure the examined fields are indexed)?
The Grails GORM does not automatically create indices for text fields unless you add the appropriate static mapping to your domain class.

MCV3: View to edit entity has to hold every column?

I got a silly general question...
If I generate a strongly typed view of an entity and chose "edit" as scaffolding, then the view does contain every column for that table. Changing and saving the values via setting it modifierd and call db.SaveChanges() does work in the controller. So far, so good.
But if I remove just one of that columns inside the view, then saving doesn't work anymore.
Is there a rule describing this? Is it only possible to make view with every column when wanting to save the model later on? I don't want to make 90 of 100 columns "hidden"...
PS: When editing a value in another table which is connected via Foreign Key (like customer.address.STREET) saving also does not work. Does everything of the entity ADDRESS has to be inside the view? I really don't get that.
Besides that: If I create my own ViewModel containing two entities: Do they also have to hold every column of both entities? This would be a whole bunch of traffic...
Answer is: You should not use the .Modified state. Instead using the UpdateModel method works fine without every field.

Resources