Hard refresh needed to display data in Umbraco.DateTime control - angularjs

I have a custom section in Umbraco, when you click a node in my custom tree, the URL is correctly displayed and the data loads successfully.
When you then click another node in the tree (sibling, exactly the same controller and view)
All the data loads...... except for the data that should shown in the calender control. If I reload the page the data loads.
For testing, I created and added an extra control but this time it is just a Umbraco.Textbox, and the data always loads correctly
So what is it about the Umbraco.DateTime all the other controls I have on the same page load drop downs, check boxes etc
Is there something I can do in my Angular(v1.6) controller to force these to update everytime?
Update: Code in my view looks like this.
<umb-property property="vm.endDateTimeTxt">
<umb-editor model="vm.endDateTimeTxt"></umb-editor>
</umb-property>
<umb-property property="vm.startDateTimePropertyEditor">
<umb-editor model="vm.startDateTimePropertyEditor"></umb-editor>
</umb-property>
<umb-property property="vm.endDateTimePropertyEditor">
<umb-editor model="vm.endDateTimePropertyEditor"></umb-editor>
</umb-property>
And For the Umbraco.DatePicker controls this is the method that genrates the property editor
function buildUmbracoClockPropertyEditor(alias, editor, view, label, description, config, mandatory = true) {
return {
editor: "Umbraco.DateTime",
label: label,
description: description,
hideLabel: false,
view: view,
alias: alias,
value: null,
validation: {
mandatory: mandatory,
pattern: ""
},
config: {
pickDate: true,
pickTime: false,
useSeconds: false,
format: "YYYY-MM-DD HH:MM:SS",
icons: {
time: "icon-time",
date: "icon-calendar",
up: "icon-chevron-up",
down: "icon-chevron-down"
}
},
}
I have also updated the format of the string when it is loaded in to the text box so now this is before a hard refresh.
And this is after
So as you can see the data is there, it gets loaded in to the text box first time you click on a node, but required me to go to my browser address bar and press enter to get the dates to load in to the Umbraco.DateTime controls.
this is just nuts! the data is there, the format is the same... what else could it be!

The reason is that Umbraco is loading all javascript on load and we need to force it to load again.
I have tried to recycle AppPool, restart website, touch web.config etc. its not easy to reload it.

Related

Customize display value of ng-multiselect dropdown value

I have a ng-multiselect dropdown. When I select all the values Instead of displaying all the values from the dropdown It should just display "All" in the dropdown.
<ng-multiselect-dropdown
[placeholder]="dropdowns.label"
[data]="dropdowns.optionsList"
[(ngModel)]="dropdowns.value"
[settings]="dropdownSettings"
(onSelect)="onItemSelect($event)"
(onSelectAll)="onSelectAll($event)"
>
this.dropdownSettings = {
singleSelection: false,
idField: 'item_id',
textField: 'item_text',
selectAllText: 'All',
unSelectAllText: 'UnSelect All',
itemsShowLimit: 3,
allowSearchFilter: false
};
When selected all the dropdowns it should display 'All' in the dropdown
you can try by changing the value of dropdowns.value with "ALL" when you select all options.
and you can do this in this event (onSelectAll).
In .ts file:
onSelectAll(event){dropdowns.value="ALL"}
It seems you have done some changes in node_module and you are not able to get changes in build. It's common in angular. Angular will not get your custom changes in the production build.
If you your custom changes works fine then use this command to make a build. With the help of this command you will get your changes in build.
ng build --aot=false
I have tried a lot for implementing the same but couldn't find any solution as it is already built library.
I've found an alternative for it. Set the itemShowLimit to 0, this means there won't be any item to display. In that case, add a span right next to the multiselect dropdown and adjust the position accordingly. Worked for me :)
Sample code:
In .ts file:
this.dropdownSettings = {
singleSelection: false,
idField: 'item_id',
textField: 'item_text',
selectAllText: 'All',
unSelectAllText: 'UnSelect All',
itemsShowLimit: 0,
allowSearchFilter: false
};
In HTML File:
<ng-multiselect-dropdown
[placeholder]="dropdowns.label"
[data]="dropdowns.optionsList"
[(ngModel)]="dropdowns.value"
[settings]="dropdownSettings"
(onSelect)="onItemSelect($event)"
(onSelectAll)="onSelectAll($event)"
><span>All</span>
I have customized display as I wanted to show the number of items selected: https://i.stack.imgur.com/BsmRN.png

angular data not binding complete data from model to view

Hi i am making a edit profile page for a user, and i am using MEAN stack
saving a fresh user works fine, now for editing the details, I have fetched the saved user from mongodb and this is what i get on the browser console( which is correct)
...
firstName: "Syed",
middleName: "",
lastName: "Faizan",
dob: "07/06/2015"
...
when i try to map these values to the View, all the data is not getting filled in the View. (i am using the same form that i used to save a fresh user, so logically it should map correctly, but it isn't).
There are other fields too that aren't getting pre- filled( only some, not showing the full json)
and i would have shown the screenshot of the webpage, but it seems i can't attach a image unless i have 10 reputation.
i tried using $scope.$apply() method, no luck.
EDIT: Jade Code for the above
form.login-form.form-horizontal(method='post', role='form' name='userForm')
input#fName.form-control(placeholder='Your first name', required, name='fName', type='text', ng-model='UI.student.firstName')
input#mName.form-control(placeholder='Your middle name', name='mName', type='text', ng-model='UI.student.name.middleName')
input#lName.form-control(placeholder='Your last name', required, name='lName', type='text', ng-model='UI.student.name.lastName')
ng-bs3-datepicker#dob(name='dob', ng-model='UI.student.dob', language='en')
....
Controller Code:
$http.get("/fetchStudentData").success(function(response){
$scope.UI.student= response;
console.log(response);
})

Extjs 4.0.7, Editor Grid - how to get updated cell value?

I need to get(retrieve) updated cell value in controller. (MVC)
So I tried this,
var modified = this.getItemGrid().getStore().getUpdatedRecords();
console.log(modified); // return [] empty array
var modified = this.getItemList_Store().getUpdatedRecords();
console.log(modified); // return [] empty array
but always it returns empty array even I updated some cell value.
anybody know what I am doing wrong?
Here is my part of view code,
Ext.define("App.view.orders.ItemList_view", {
extend: "Ext.grid.Panel",
alias: "widget.itemList_view",
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
initComponent: function () {
this.store = "ItemList_store";
this.columns = [
{
xtype: 'checkcolumn', text: "Ship", width: 50, dataIndex: "DR"
},
{ header: "test", width: 100, dataIndex: "test",
editor: {
xtype : 'textfield'
}
}
];
this.selModel = Ext.create("Ext.selection.CheckboxModel");
//this.selModel = Ext.create("Ext.selection.CellModel"); // It does not works either.
this.callParent(arguments);
},
.
.
.
Thank you!
[EDIT]
Thank you very much for your answer! I have some more question about editor grid.
Its much different from Ext3. so I'm very confusing now :(
Q1. How to collect edited record data (once click button)?
the event fired once the grid cell be changed.
but I want collect edited grid record once I click the 'Update edited cell' button, and I want to update all together at the once.
In Ext3, I did like this,
(button) click : function(){
var modified = mygridStore.getModifiedRecords();
var recordsToSend = [];
Ext.each(modified, function(record){
recordsToSend.push(record.data);
});
var grid = Ext.getCmp('grid');
grid.el.mask('Updating','x-mask-loading');
grid.stopEditing();
recordsToSend = Ext.encode(recordsToSend);
Ext.Ajax.request({
url : '/test/test',
params : {
data : recordsToSend
},
success : function(response){
grid.el.unmask();
alert(response.responseText);
mygridStore.commitChanges();
},
failure : function(response){
mygridStore.rejectChanges();
}
});
}
How can I change the code for Extjs4 ?
Q2. I don't know still how to find out for changed checkcolumn.
I tried this, but I does not work for checkcolumn (of cause I tested after change checkbox)
// grid coumn
{
xtype: 'checkcolumn', header: "My Check Column", width: 50, dataIndex: "CH"
}
-
// in control
'myGrid': {
validateedit: function (plugin, edit) {
console.log(edit);
},
checkchange: function (plugin, edit) {
console.log(edit);
console.log(edit.value);
}
}
Q3. When I click the cell to edit, the show some HTML tag in -_-;;
I really appreciate for your help. and thank you very much for your valuable time!
The editors (cell editors or row editors) do not commit their values to the store until you complete the edit - which means pressing ENTER or blurring the active cell editor by clicking elsewhere on the page, or clicking the save button on the row editor form .
If your purpose for reading the updated value in your editor is to perform some kind of validation I would suggest simply listening to the validateedit event in your grid's controller, as described here.
The second argument that this event passes to your handler contains a lot of data about the edit that you can then perform validation with. If the edit doesn't pass your validation you can return false from your handler and the value in the celleditor will revert to it's original value. The validateedit event gets fired from the editor grid itself so you would add an event handler in your controller for it like this:
Ext.define('MyApp.controller.MyController', {
init: function() {
this.control({
'mygridpanel': {
validateedit: function(plugin, edit) {
// silly validation function
if (edit.value != 'A Valid Value') {
return false;
}
},
},
});
},
});
But you should check out the link above to see all the different objects available in that second argument I named edit.
The validateedit event is fired right before the record is committed into the store - after the user has already clicked ENTER or blurred the editor, i.e., while the editor is closing.
If you are trying to get the celleditor's value before it starts to close, for some reason other than validation for example, you could get the active celleditor's value like this:
// myGrid is a reference to your Ext.grid.Panel instance
if (myGrid.editingPlugin.editing) {
var value = myGrid.editingPlugin.getActiveEditor().field.value
console.log('value: ' + value);
}
If there is no active editor then myGrid.editingPlugin.getActiveEditor().field would throw an error, that's why I wrapped a conditional around it.
One other point I should make, for validation in editor grids, I found that it is easiest to just put a validator config in the grid column's editor definition. That will give you all the handy validation CSS while the user is setting the field's value and alert him if there is a problem with the value before he tries to save it.
To get an idea of what I mean, try entering letters in the date column of this example. Mouse over the editor cell and you will get the error message.
EDIT
It seems I misunderstood you original question, I'll break down my answers to your questions above though,
Question 1
Once you have completed an edit (clicked ENTER or ), your call to mygridStore.getModifiedRecords() should be working fine because the record will have been committed to the store. I see that it was not working, I will cover that in a moment.
I should point out that ExtJS4 has a store.sync() method as covered here.
Instead of extracting the modified records from the store, encoding them, manually doing an ajax request to save them to the server and then manually committing them you can call this sync method and it will take care of all of these actions for you.
If you have different URLs to handle the different create, read, update, destroy operations fired off by your store's load and sync methods, you can use the store's proxy api config to map your URLs to these operations as covered here. Or you can set-up your server side controller to be able to differentiate between your store's load request (read operations default to HTTP GET) and it's sync requests (create, update and delete operations default as HTTP POST).
There could be many different ways to go about doing this on the server side, the way I usually do it is to have one SQL stored procedure for GET requests and one for POST requests for any given store. I include the store name as an extra param and then my server side controller runs the appropriate stored procedure based on whether it is a GET or a POST request.
Question 2
Cell editing doesn't support checkcolumn edits. You have to make a different handler to listen to changes on that, something like this:
checkchange: function (column, rowIndex, checked) {
var record = store.getAt(rowIndex),
state = checked ? 'checked' : 'unchecked'
console.log('The record:');
console.log(record)
console.log('Column: ' + column.dataIndex);
console.log('was just ' + state)
}
Your call to mygridStore.getModifiedRecords() should be able to pick up the check changes also however, they get committed to the grid's store right away after being checked. store.sync() would also pick up changes to checkcolumn.
Question 3
I can't completely tell what is causing that problem but it may be something strange going on with your validateedit event, your handler should be returning true or false.
As I said earlier, I misunderstood the reason you originally asked this question. I thought you were trying to do some kind of validation while an edit was in progress. Now I understand that you are trying to get all of the modified records from the store after all the editing is completed in order to save them to the database, I was thrown off because in ExtJS 4 a store is usually saved to the database with the sync method as I mentioned.
In other words, you don't need the validateedit event or checkchange event to get a list of modified records.
The actual problem you are having might be trouble with the store's getter methods (getModifiedRecords, getUpdatedRecords) in some 4.07 versions, take a look at this post and this one.
So with all that said, the best advice I can give you is 1) try out the stores sync method for saving modified data to the database and 2) upgrade to ExtJS 4.1, there were a lot of bugs that were straightened out between 4.07 and 4.1 which you should be able to take advantage of, I cut out about 75% of the overrides I was using to make things work when I switched over to 4.1.
EditedGrid.plugins[0].completeEdit();
This will make the active changes commit and call edit event also.
listeners: {
validateedit: function (editor, e) {
//console.log(editor);
var oldVal = editor.originalValue;
var newVal = editor.value;
}
}

Ext.js4 -- Adding a box to the top of a panel rather than to the bottom

I am using Ext.js 4. I have a panel which contains log messages returned from the server.
The following will append the most recent messages to the that panel:
// show log on the log panel
logPanel.add( { xtype: 'box', autoEl: { cn: theText } } );
I also add a separator bar between messages:
// add a separator bar
logPanel.add( { xtype: 'box', autoEl: { html: '<hr/>'} } );
I thought about clearing the panel before adding new messages, so only the most recent messages appear, and this works (when placed before the above):
// the following will remove prior log messages...
logPanel.removeAll();
But what I would really like to do is simply put the most recent messages BEFORE the previous messages (the default action of the add method is AFTER).
Any suggestions on how I could do that? Thanks in advance.
Use the insert method: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.container.AbstractContainer-method-insert

ExtJS Paging Toolbar start page

I have an ExtJS GridPanel with a store and a paging toolbar at the bottom. I can manually set the start page through the browser using:
www.someurl.com/page/7
This will load the data store with page 7 correctly. However, the paging toolbar does not update the page number from the store (it still shows 1). I was under the impression that by changing the page of the store also changes the page in the paging toolbar, but this is not the case. Here is some example code:
var _store = new Ext.data.Store({
id : 'store_id',
remoteSort : true,
autoDestroy : true,
restful : true,
proxy : _proxy,
reader : _reader,
writer : _writer
});
var _pagingToolbar = new Ext.PagingToolbar({
displayInfo : true,
pageSize : 20,
store : _store
});
_I.grid = new Ext.ux.GridPanel({
id : _I.options.id+'_grid',
title : _I.options.title,
store : _store,
bbar : _pagingToolbar
});
_I.options.page = 7; //start store on page 7
_I.grid.render('somediv');
_store.load({params:{start:_I.options.page, limit:20, sort:'id', dir:'ASC'}});
Since the start page is set to 7, the data that loads in the store is correct, however, the page in the paging toolbar reads 2. I have tried manually setting the page with
_pagingToolbar.changePage(20); // should set page to 20
I get the same result, the data store loads up the correct page, however the toolbar text does not change. Is the order wrong? I also tried loading the store before the grid is rendered, to no avail, with same result.
As the store and the paging bar are inhernatly linked, you should simply be able to use the .changePage(n) method to change the page and automatically adjust the content of the store. You shouldnt need to also code the store with a recordset update. Also, are you 100% sure the store is displaying the correct records for page '7'?
What pagination info are you returning from the server side? PagingToolbar just takes that info from the store.
Could you please show your reader and the part of server response showing pagination data?

Resources