I have a parent route. it has the model which is used by all child routes. when i consume the parent model from one of child ( first page ) I am updating the model like this:
selectedList : Ember.computed.map('model.selectedTrans', function(card,index){
return Ember.Object.create({
count : index + 1, //adding new info
countSize : this.get('model.selectedTrans').length,
durations:[6,12],
duration:12 //adding new info
})
}),
after this, I am taking the user to next page ( sibling of updated page ), but when i try to fetch the updated info, I am not able to get it. the updated info not at all available there is next page.
what is the issue here? or how to update the local model? ( I am not sending or fetching from server )
Related
I am a new user of kendo and I have a problem with a gantt!
I have a page with a Gantt kendo. For each activity I have a button edit. When my popup edit is open I have lot of fields and a multiselect. This multiselect should be specific for each activity.
I have put the code below in my function edit Gantt :
$.get('/Activity/ReadMultiSelectActivities?initiativeId=' + #Model.ID + '&excludeSectorId=' + $('#SectorID').val() + "&activityID=" + e.task.id, function (data, status) {
allActivitiesDataSource = new kendo.data.DataSource({
data: data.Data,
group: { field: "SectorName" },
sort: { field: "ActivityNumberString", dir: "asc" }
});
});
var msLinkedActivities = $('#linkedActivities').data('kendoMultiSelect');
msLinkedActivities.setDataSource(allActivitiesDataSource);
My problem is that I get the impression that my code is read into account with a delay time. That is, if I click on edit activity 1 the first time the list is empty, I close the edit and then return to edit activity 1 the list is filled. If then I go on edit activity 2 it will be the list of activity 1 ...
I tried many things that I view on tuto, demo and forum telerik but nothings function!
Have you an Idea for fix this problem please?
For information I have resolve my probelm. This is because the data are long to retrieve and so it made the setDataSource before loading the data!
If I create an item in sitecore from code behind using following code as shown in example under the heading Creating items:
//Now we can add the new item as a child to the parent
parentItem.Add("NewItemName", template);
And then in order to get the this newly added item from sitecore database what I should do? Because I don't know the ID.
The new item will be returned by the add method.
Eg.
Item newItem = parentItem.Add("NewItemName", template);
I've created a custom field for sitecore Item, this custom field just creates a new Item with name specified under some specific folder. I do it on save (appropriate condition in onLoad method for custom field control):
if (!Sitecore.Context.ClientPage.IsEvent)
{
//blah-blah-blah
}
else
{
TemplateItem template = db.GetTemplate(TemplatePath);
Item parentItem = db.Items[ItemsRootPath];
var newItem = parentItem.Add("item name", template);
}
Item is creating successfully, but content editor automatically opens this item when I save a parent item (item that contains this custom field).
The question is: how I can avoid it and create this item in background, without displaying it to user?
Thanks,
A
You can disable Notifications which will prevent the new item being loaded like so:
Client.Site.Notifications.Disabled = true;
TemplateItem template = db.GetTemplate(TemplatePath);
Item parentItem = db.Items[ItemsRootPath];
var newItem = parentItem.Add("item name", template);
Client.Site.Notifications.Disabled = false;
I tested this by adding a child to the item that I was saving and resulted in the tree not being updated as well. I fixed that by adding this line after the notification enable.
Sitecore.Context.ClientPage.SendMessage(this, string.Format("item:refreshchildren(id={0})", ItemID));
I have hooked up the content of ember-table with an ember-data model. I'm trying to get model object underlying the row that is currently selected. I've tried using this.get('selection') but to no avail. My ultimate goal is that i have an associated edit details view in a separate view that sits next to the table (aka list view) with a router (v2) that handles the transitioning between creating new models to insert into the table and edit the currently selected model (or eventually batch edit multiple models in the table). Here's the code sample:
App.TableView = Ember.Table.TablesContainer
.extend(Ember.Table.RowSelectionMixin).extend({
selectionBinding: 'controller.selection'
});
App.TableController = Ember.Table.TableController.extend({
...
selection: null,
selectionChanged: Ember.observer(function() {
this.transitionToRoute('selectedModel.edit', this.get('selection'));
}).observes('selection'),
...
I have solved this issue. What i hadn't realized is that selection is an enumerable (i'm guessing in preparation for multiple selection which would be awesome!) In the controller:
selection: null,
selectionChanged: Ember.observer(function() {
if(this.get('selection').length) {
selection0 = this.get('selection')[0];
this.transitionToRoute('selectedModel.edit', selection0);
}
}).observes('selection'),
I need to customize how the m2m widget for Django Admin gets displayed but I am kind of stumped where to start. I have tried subclassing couple of widgets from django.forms and django.contrib.admin.wigets but nothing seems to be working.
Here's a depiction of what I am looking for http://i.stack.imgur.com/81AY3.png.
Any help appreciated.
That looks like the kind of thing that could be achieved with JavaScript alone. For adding your own JavaScript to the Django admin, see the documentation for ModelAdmin media definitions.
This is what I came up with. It does most of the work. However, the list does not get updated when a new item is added and changing an item does not redirect back to the original page.
/your_app/forms.py
class ProductForm(forms.ModelForm):
class Media:
js = ('js/custom_m2m.js',)
class Meta:
model = Product
/your_media/js/custom_m2m.js
django.jQuery(function() {
var $ = django.jQuery;
// Add a new place holder div to hold the m2m list
$('div.options div').append('<div class="newdiv"></div>');
// Assign some variables
var target = "options"; // <-- Target Field
var newdiv = $('div.newdiv');
var next_page = window.location.pathname;
var add_link = $('div.'+target+' div a#add_id_'+target);
var edit_img = "/static/media_admin/img/admin/icon_changelink.gif";
var add_img = "/static/media_admin/img/admin/icon_addlink.gif";
// Make the placeholder div bit nicer
newdiv.attr("style", "line-height:20px; margin-left:105px;");
// Iterate through select options and append them to 'newdiv'
$('select#id_'+target+' option[selected="selected"]').each(function() {
newdiv.append(''+$(this).text()+' <img src="'+edit_img+'" /><br />');
});
// Add a 'Add new' link after the option list
add_link.html('<strong>Add new</strong> ' + add_link.html());
add_link.appendTo(newdiv);
// Show the 'newdiv' and hide the original dropdown
$('select#id_'+target).after(newdiv);
$('select#id_'+target).css("display", "none");
$('div.'+target+' p[class="help"]').css("display", "none");
});
As you can see, the above script uses some hardcoded paths. Any improvement would be helpful.