I have been working with ribbon workbench 2016 beta and smart buttons and I realized that there is not a function to redirect on click.
What I want is when I do click on a button which create a new entity record that these action redirect me to the new entity record that it has created... This entities are, orders and delivery note. The two entities are related. The button is located in the first entity.
Do you have any idea how to do it?
This is the button
And this is the page where i want to be redirect.
To redirect you have to create a new js that is called by the command on the ribbon button.
Get the value of the related entity and populate it in a new window.
function Redirect()
{
var URL= Xrm.Page.getAttribute("relatedentityurl").getValue();
if (URL != null || URL != "")
{
window.open(URL, '_blank');
}
}
Related
I am using mvc3 application where after click on login button i am checking that user is validated or not using ajax call in jquery. If user is authenticated then i return true and in Onsuccess method i am redirecting it to home page. Below is the code:
function OnSuccess(response) {
var mesg = $("#lblMess")[0];
switch (response) {
case true:
var url = "/Home/Search";
takeToHomePage(url);
$(location).attr('href', url);
break;
case false:
mesg.style.color = "red";
mesg.innerHTML = "Email id or Password is incorrect";
break;
case "error":
mesg.style.color = "red";
mesg.innerHTML = "Error occured";
break;
}
}
Till here working fine. Now i added one signout button in _layout.cshtml page which i made visibility none in login page, so if i show this signout button before switch starts and user is not valid then signout button displays but if user is authenticated and trying to show signout button inside true case then it is not working.
Need help.
Now i added one signout button in _layout.cshtml page which i made
visibility none in login page, so if i show this signout button before
switch starts and user is not valid then signout button displays but
if user is authenticated and trying to show signout button inside true
case then it is not working.
Make a Ajax call to server to check if user is authenticated or not. And then you can toggle the button show and hide. This is not the best method to do it. But talking about good approach would be to create a custom CustomPrincipal by inheriting ICustomPrincipal and may more changes. which I think would be too much for you if you have just started on MVC.
This solution is only to toggle the sign-out button visibility and I am not proposing this as best practise.
$.get("User/CheckUserAuthenticity",function(response){
if(response == "true")
{
//button show;
}
});
your Controller Action can be
public ActionResult CheckUserAuthenticity()
{
return Json(User.Identity.IsAuthenticated,JsonRequestBehavior.AllowGet);
}
Here is my situation:
I have a very long multi-page survey built by webforms in drupal.
The questions are not required but we don't want the users to skip all the questions too easy by just clicking Next Page button.
So this is what we need:
When the user try to click on "Next Page" button with any empty fields on the page, error or warning messages will show up, "Are you sure you want to skip this question?", as well as a skip button next to it. When the user click on the skip button, the message disappears and they click on the next page button to proceed the survey.
Here are my thoughts on this:
I used webform validation module to create an Not Empty validation and apply it to the fields.
in webform_validation_validators.inc:
case 'skip_if_empty':
foreach ($items as $key => $val) {
if (count($val) == 0) {
drupal_set_message(t('This field is empty.'), 'warning');
// do something, not sure about it here
}
}
Another thought:
I used the Dismiss module to display an X button next to the error message.
Can I add some functions to the X button to bypass the validation when it is clicked?
And here is the script for the Dismiss module, :
(function ($) {
Drupal.behaviors.dismiss = {
attach: function (context) {
$('.messages').each(function () {
var flag = $(this).children().hasClass('dismiss');
if (!flag) {
$(this).prepend('' + Drupal.t('Close this message.') + '');
}
});
$('.dismiss').click(function () {
$(this).parent().hide('fast');
// some functions to bypass validation to the field?
});
}
}
})(jQuery);
I don't know what to do to after the //. Or is there any other ideas that will work?
AS per the you requirement mention
Take this example
You have created webform having field like
Firstname with required field
Lastname with required field
Then Next button button
When user click next button then error show because you have make the fields are required
When your showing "Dismiss button" next to each field.
Whenr user click "Dismiss button" that time you have to remove "required" attribute of field using jquery or drupal ajax
After that when user click next button then user not get any kind of required field validation error.
I have hyperlink column in grid and clicking the link i want to open a popup. Below is my code.
cols.Bound(o => o.PO_NO)
.ClientTemplate(
Html.ActionLink("<#=PO_NO#>",
"SurPODtls",
new { controller = "Home", PO_NO = "<#=PO_NO#>" },
new { target= "_self" }).ToString())
.Title("PO No").Width(30).Filterable(false);
In SurPODtls action method iam returning the partial view of SurPODtls, which contains the telrik window in which iam again calling the partial view to load the controls and data. And same time i have to retain the grid.
But this not works for me. Please provide solution, if anyone have idea
you can use the Custom Column Command here is the link http://demos.telerik.com/aspnet-mvc/grid/customcolumncommand
I'm trying to implement a simple listview / detailview feature in one of our apps. I'm using the MVCContrib Grid (which btw is awesome!) to show the list of items. There's an edit link next to every row on the grid that allows the user to edit the item. When the users click the edit link I execute a Get that returns the details form used to editing the item. For some reason I cannot get the clicked customerId to be sent to the controller. The controller just gets null every time I click the edit link.
My grid is configure like so:
Html.Grid(Model.CheckAccounts)
.Columns(column.For(c => {Html.ActionLink(
"Edit",
"CustomerDetails",
"CustomerManagementController",
new {Id=customer.Id}));
column.For(c => c.Name);
column.For(a => c.AccountNumber);
}).Render();
Here's My controller Action:
[HttpGet]
public ActionResult CustomerDetails(long? Id )
{
//fetch the customer from repo...
//return it to the client
return View(model);
}
I'm totally confused since all the samples and blogs I've seen, access data from the grid the same way I'm doing it. Can someone help?
I hate to answer my own question but I was able to fix this by changing the action link to:
{Html.ActionLink(
"Edit",
"CustomerDetails",
"CustomerManagement",
new {Id=customer.Id}));
I realized the wrong action link was being generated after looking at the "?Length=24" queryString parameter at the end of the URL.
The grid is working as expected now.
I have a simple ExtJS application that is written MVC style (much of my information from here).
My application creates a viewport, and has a view with a form, some fields and a button.
The application has a controller with a 'loginButtonClick" function, and the controller watches the click event with a:
this.control({
'loginwindow button[action=save]': {
click: this.loginButtonClick
}
}
That works great, but now when the login window is showing, I want the enter key to also execute the loginButtonClick method.
I have tried all kinds of things, but the basic issue I am having is WHERE to put the code for creating the keymap, and how to bind it to the proper instances.
For example, if I create the keymap in the controller (which is my preference), I need to get the specific view instance for that controller (I might have multiple windows open of the same kind).
So, How would you create a key map (or?) from within a controller for it's view (window), calling a local method (this.loginButtonClick) when the enter key is pressed?
What you can do is bind the code that initializes the keyMap to the login window afterrender event like this:
this.control{(
'loginwindow' : {
afterrender: this.initializeKeyMap
}
Then make a function that sets up the keyNav:
initializeKeyMap: function(window, options) {
this.keyNav = Ext.create('Ext.util.KeyNav', window.el, {
enter: this.loginButtonClick,
scope: this
});
}
Now when the dialog is loaded if the user presses the Enter key, it should execute your function.
You could setup all these things on your window render event. So when it is rendered you add an eventlistener for the enter key, and in the handler you call programatically click on the login button.
You can achieve this by adding the following listeners to your text/password fields in the form
listeners: {
specialkey: function(field, e){
if (e.getKey() == e.ENTER) {
var form = this.up('form').getForm();
submitLoginForm(form);
}
}
}
Here 'form' is your form and 'submitLoginForm' is the function called at form submit which I guess is loginButtonClick in your case.
Hope this helps.