joomla 3 custom component checkout record - joomla

Iam in the edit view of one of my component views.
When I go back to the list view, with the cancel button of joomlas toolbar, the list view appears, but the record is locked. It seems that the record is not checked out correct.
In this case, there is no special function in the appropriate controler for canceling. Only for saving and some other tasks.
Iam not able to unlocking the records due to my view in the backend.
In the view there is a typical javascript for using the submit button:
<script type="text/javascript">
js = jQuery.noConflict();
js(document).ready(function() {
});
Joomla.submitbutton = function(task)
{
if (task == 'master.cancel') {
Joomla.submitform(task, document.getElementById('master-form'));
}
else {
if (task != 'master.cancel' && document.formvalidator.isValid(document.id('master-form'))) {
Joomla.submitform(task, document.getElementById('master-form'));
}
else {
alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); ?>');
}
}
}
</script>
Where should I go into, to activate the checkout function when leaving back to the listview from the edit view?
Same problem in case of saving records.
thx Perino

I found the problem. The view is build up of different models and I deactivated
$this->item = $this->get('Item');
in view.html.php. Activating, will result in correct checkin/out of the record.

Related

Refresh Parent Form after Quick Create in Dynamics CRM 2016

In Dynamics CRM 2016 we have a Quick Create Form which works well. But once the Quick Create is done, and the record is saved (and the new record appears in the sub-grid in the parent form), the roll-up field under the sub-grid doesn't get re-refreshed on the screen until the user presses F5.
(we have some C# code to update the roll-up).
Does anyone know how to force the refresh of the main form after the Quick Create has successfully run?
You may add timeout on refresh event, and after 1-2 sec refresh once more.
function OnFormLoad() //add this function onload form
{
var subGrid = window.parent.document.getElementById("id of your subgrid")
if (subGrid !== null) {
if (subGrid.control)
subGrid.control.add_onRefresh(fnOnRefresh)
else
setTimeout(OnFormLoad, 500);
} else {
setTimeout(OnFormLoad, 500);
}
}
function fnOnRefresh() {
setTimeout(function() {
Xrm.Page.ui.controls.get("id of your subgrid").refresh();
}, 2000) //after 2 sec refresh subgrid
}
I would try stopping the OOB save event using the below snippet: Read more
function onSave(context) {
var saveEvent = context.getEventArgs();
saveEvent.preventDefault();
//save explicitly here
//reload the window here
}
And then save the entity in code using:
Xrm.Page.data.entity.save();
And then refresh/reload the browser window. I haven’t tried this but very rough theory :)
We got it working ... used what Timur suggested but just changed the last function to:
function fnOnRefresh() {
setTimeout(function() {
window.parent.location.reload(true);
}, 500)
}
Thank you

dynamics crm 365 online quickform not rendering

I have a form which has a tab and in this tab is a quickview form. On the quickview form, I have a subgrid and a text field.
The tab has a default state of 'collapsed'. When I open the form, only the text field is displayed. It seems as if the subgrid in no rendering at all.
If I change the tab default state to 'expanded', then when I open the form, the
subgrid is rendering correctly.
I have tried to refresh the quickform view outlined here
https://msdn.microsoft.com/en-us/library/mt736908.aspx
But it does not seem to work.
UPDATE:
I have tried the following, but still no success.
FIRST VERSION
// Triggering when the tab is expanded
function onChange(){
console.log('on change');
// get quick view form
var qv = Xrm.Page.ui.quickForms.get("myquickformview");
qv.refresh();
// get subgrid
try {
qv.getControl(0).refresh();
}
catch (e)
{
console.log(e);
}
}
SECOND VERSION
function onLoad(){
console.log('onload');
Xrm.Page.getAttribute('new_person').addOnChange(refresh);
}
function onChange(){
Xrm.Page.getAttribute('new_person').fireOnChange();
}
function refresh(){
console.log('on change');
// get quick view form
var qv = Xrm.Page.ui.quickForms.get("myquickformview");
// get subgrid
try {
qv.getControl(0).setVisible(false);
qv.getControl(0).setVisible(true);
qv.getControl(0).refresh();
}
catch (e)
{
console.log(e);
}
qv.refresh();
}
Any advice appreciated. Thanks in advance.
1.Add onchange event handler for the lookup (on which Quick view form is rendered) to have the code to refresh the quick view control.
Xrm.Page.getAttribute("lookup_fieldname").addOnChange(function);
Keep the below code in function.
var quickViewControl = Xrm.Page.ui.quickForms.get(“your quick view form name”);
if (quickViewControl != undefined) {
if (quickViewControl.isLoaded()) {
quickViewControl.refresh();
}
}
2.Trigger fireOnChange() of lookup on tab expanded handler, so that onchange will refresh QVform totally.
Xrm.Page.getAttribute("lookup_fieldname").fireOnChange();
Got a hint from this. I just answered here (in mobile without testing) to unblock you.

Clear Session Storage when Clicking Outside

I'm using Meteor and have the code below that stores _id into session:
'click .players': function(){
var playerId = this._id;
Session.set('selectedPlayer', playerId);
The session above is set when user clicks within <li class="players">
I would like to clear the session data when user clicks outside of <li class="players">
What will be the best way to do this?
Thanks !
This solution is a little limited, because the selector :not("li.players") is within the template, which means that you may click somewhere outside the template and it will not fire a click event. It is advisable to put the click event under body template but it will still not fire a click event when you click the html part.
if (Meteor.isClient) {
Template.body.events {
'click :not("li.players")': function(e) {
Session.set('selectedPlayer', null);
}
}
}
For more precisely, this might help you out.
if (Meteor.isClient) {
$(document).click(function(e) {
e.stopPropagation();
var target = $(e.target);
var players = $('li.players');
if (!players.is(target) && players.has(target).length === 0) {
Session.set('selectedPlayer', null);
}
})
}
You can do:
'click :not(".players")': function(ev){
Session.set('selectedPlayer',null);
}
:not() css selector docs

How Do I Reselect A KendoUI TabStrip After AJAX Postback in UpdatePanel

Setup
I've got a Telerik Kendo UI TabStrip with multiple tabs inside of an UpdatePanel...
<asp:UpdatePanel ID="DataDetails_Panel" UpdateMode="Conditional" runat="server">
<div id="ABIOptions_TabContainer">
<ul>
<li>Attendance</li>
<li>Grades</li>
<li>Gradebook</li>
<li>PFT</li>
<li>Scheduling</li>
<li>Miscellaneous</li>
<li>Parent Data Changing</li>
</ul>
</div>
</asp:UpdatePanel>
...which I then wire up in javascript later...
var optionTabContainer = $("#ABIOptions_TabContainer").kendoTabStrip({
animation: {
open: {
effects: "fadeIn"
}
},
select: onMainTabSelect
}).data("kendoTabStrip");
Scenario
The users will click on the various tabs and inside of each tab are settings for our portal. When they are in a tab and they make a change to a setting, the expectation is that they'll click on the 'Save' button, which will perform a postback to the server via ajax, because it is in the update panel.
Current Behavior
After the post back happens and the ul content comes back, I reapply the kendoTabStrip setup function call, which makes none of the tabs selected. This appears to the user like the page is now empty, when it just had content.
Desired Result
What I want to do, is after the partial postback happens and the UpdatePanel sends back the ul, I want to reselect the tab that the user previously selected.
What Already Works
I already have a way to preserve the tab that the user clicked on:
var onMainTabSelect = function (e) {
tabToSelect = e.item;
console.log("onTabSelect --> ", e.item.textContent);
}
and a function to reset the selected tab whenever it is called:
function setMainTab() {
if (!jQuery.isEmptyObject(tabToSelect)) {
var tabStrip = $('#ABIOptions_TabContainer').data("kendoTabStrip");
console.log("Attempt to set tab to ", tabToSelect.textContent);
tabStrip.select(tabToSelect);
} else {
console.log("tabToSelect was empty");
}
}
What Doesn't Work
My hypothesis is that the Kendo TabStrip says, "Hey, that tab is already selected" when I call the setMainTab after my postback:
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
BindControlEvents();
setMainTab();
});
...and therefore, doesn't set my tab back. If I click on the tab, then Poof, all my content is there just like I expect.
Any ideas what I may be doing wrong?
I ended up changing the onMainTabSelect method to:
var onMainTabSelect = function (e) {
tabToSelect = $(e.item).data("tabindex");
}
which gets me the data-tabindex value for each li in my ul. I couldn't get the tab index from kendo, so I had to role my own. Once I got that value, then I was able to set the selected tab via an index rather than the tab object reference itself.

Wordpress Create Category AJAX Response

I currently have a plugin that allows a user to activate/deactivate categories to drive a menu. I've created an option for the toggle and have it functioning in the create form and edit form seamlessly. The only place I can't seem to add it is to the AJAX return from wordpress when the category is created. I can create the column when the Categories page is loaded but don't know how to tap into the AJAX Return without modifying the core. Is there a hook that I'm unaware of that allows you to modify this return?
Using Akmal's answer, this is my script to check if the Taxonomy-Category was created or not.
Thanks Akmal.
Wordpress version 3.8.2
$(document).ajaxComplete(function(event, xhr, settings) {
var queryStringArr = settings.data.split('&');
if( $.inArray('action=add-tag', queryStringArr) !== -1){
var xml = xhr.responseXML;
$response = $(xml).find('term_id').text();
if($response!=""){
console.log('This is the action.');
}
}
});
Do you try to run some Javascript after ajax return (after add new category)?
Try to put below code in your code when you create the custom field in category form :
$(document).ajaxComplete(function(event, xhr, settings) {
var queryStringArr = settings.data.split('&');
if ($.inArray('action=add-tag', queryStringArr) !== -1){
your_javascript_function(); //this is your js function
}
});

Resources