kendo inline editing enable and disable fields - kendo-ui

How i can enable certain fields on add mode and disable on edit mode. I have add the following code but i unable to enable the description field on add mode. Please advise how I can achieve this?. Thank you
model.fields(p=> p.Description).Editable(false);
I want to enable description on add mode and disable on edit mode. THe following code is not working. Please advise if anything wrong with the code and if any other way to do it. THank you
function onEdit(e) {
var indexCell = e.container.context.cellIndex;
var grid = $('#BTSession').data('kendoGrid');
if (!e.model.isNew()) { // when Editing
if (indexCell != 'undefined' && grid.columns[indexCell].Title == "Description") {
$('#BTSession').data("kendoGrid").closeCell();
}
}
}

There are two problems:
The title is lowercase. The check should be: grid.columns[indexCell].title
isNew() is always false. Alternatively you might check for id being undefined when you add a new record.
Something like:
function onEdit(e) {
var indexCell = e.container.context.cellIndex;
var grid = $('#BTSession').data('kendoGrid');
if (e.model.id) { // when Editing the id is defined
if (indexCell != 'undefined' && grid.columns[indexCell].title == "Description") {
grid.closeCell();
}
}
}
NOTE: If in your model the id column is not called id (lets say myId) use the correct name.
EDIT: See a running example here

Related

Is there a way to make a field in Dynamics CRM as one time entry field?

Basically, what I want is that the user should be able to select the dropdown and not be able to change it after making and saving the selection. So it will be a one-time entry field.
Below is a screenshot of the field I want to apply this property.
So this field has a Yes or No selection. And to make the business logic from failing I have to make it a one-time entry field only.
I looked up the form editor for possible things but couldn't find anything that would let me achieve this.
UPDATE #1
Below is my onload function:
function Form_onload() {
var formType = Xrm.Page.ui.getFormType();
var p = Xrm.Page.getAttribute("opportunityid");
--------------NEW CODE--------------------------------
if(formType ==2){ //form type 2 means the form is a saved form. form type 1 is new form.
alert(formType);
var myattribute = Xrm.Page.getAttribute("var_internal");
var myname = myattribute.getName();
if (Xrm.Page.getControl(myname) != null) {
//alert(myname);
Xrm.Page.getControl(myname).setDisabled(true);
}
}
--------------NEW CODE---------------------------
if (formType == 1 && p != null && p.getValue() != null) {
alert('Child Opportunities can only be created by clicking the Create Child Opportunity button in the Opportunity ribbon.');
window.top.close();
}
}
No code solution: I think you could use an Option set with a Yes/No option and a default of Unassigned Value. Then add that field to Field Level Security with "Allow Update" set to No.
When updating the FLS field permissions, be sure that the profile is associated with the organization "team" so that all users can see the field:
Arun already gave you an hint how to proceed, I just tried this req on one of my instance.
Create one extra field (dummy field) in my case I call it new_hasfieldbeenchanged1
This field will hold data when field is changed. Lock this field (always) and keep this field on form (but visibile =false)
Now you need 2 trigger Onload and OnSave. Below function will do your work. Let me know if this helps.
function onLoad(executionContext) {
debugger;
var formContext;
if (executionContext && executionContext.getFormContext()) {
formContext = executionContext.getFormContext();
//executionContext.getEventSource()
if (formContext.getAttribute("new_hasfieldbeenchanged1") && formContext.getAttribute("new_hasfieldbeenchanged1").getValue()!=null) {
if (formContext.getControl("new_twooptionfield")) {
formContext.getControl("new_twooptionfield").setDisabled(true);
}
}
}
}
function onSave(executionContext) {
debugger;
var formContext;
if (executionContext && executionContext.getFormContext()) {
formContext = executionContext.getFormContext();
//executionContext.getEventSource()
if(formContext.getAttribute("new_hasfieldbeenchanged1") && formContext.getAttribute("new_twooptionfield") && formContext.getAttribute("new_twooptionfield").getIsDirty()){
formContext.getAttribute("new_hasfieldbeenchanged1").setValue((new Date()).toString());
if (formContext.getControl("new_twooptionfield")) {
formContext.getControl("new_twooptionfield").setDisabled(true);
}
}
}
}
Due to environment-specific settings in my DEV, I was not able to reproduce what was suggested by #Eccountable. Although, his solution worked in other environments.
#AnkUser has a good answer as well but I was looking to shorten the code and make things as simple as possible.
My solution
I was able to handle this using Javascript on client-side. using the XRM toolbox.
In the XRM toolbox, I located the javascript for the opportunity and observed field changes in formType when the Opportunity was New and when the Opportunity was Existing. This variable (formType) was =1 when the Opportunity was New and =2 when it was Existing/Saved.
Using this piece of information I was able to leverage my Javascript as follows in Form_onload()
function Form_onload() {
if (formType == 2) {
var myattribute = Xrm.Page.getAttribute("internal");
var myname = myattribute.getName();
if (Xrm.Page.getControl(myname) != null) {
Xrm.Page.getControl(myname).setDisabled(true);
}
}
}
There’s no OOB configuration for such custom requirements, but we can apply some script logic.
Assuming this is a picklist with default null and not a two-option bool field, we can use onLoad form script to check if it has value & lock it. No need to have onChange function.
If it’s a bool field, then it’s hard to achieve. You have to track the initial value & changes made to implement the logic you want. Or through some unsupported code.

Dynamic menu configuration section with conditional inputs on Magento custom module

I've followed this tutorial to create a custom dynamic backend configuration with serialized data, and everything is working as expected. yay
But now I want to take another step and only show some inputs when a specific value is selected in a select box. I know that I can use when doing this with system.xml, but how can I accomplish the same thing via code with dynamics serialized tables?
I ended up doing some kind of Javascript workaround to enable/disable a certain input.
function togleSelect(element)
{
var val = element.value;
var name = element.name;
if (val == 0) // select value to be triggered
{
name = name.substr(0, name.lastIndexOf("[")) + "[name_of_my_input]";
var target = document.getElementsByName(name);
target[0].disabled = false;
}
else
{
name = name.substr(0, name.lastIndexOf("[")) + "[name_of_my_input]";
var target = document.getElementsByName(name);
target[0].disabled = true;
}
}
It's not the best solution but it's working.

Angular 2 Pass Enum to Components Function from HTML

I have created an enum to open up a modal based on whether its an add or an edit modal.
enum ModalTypes {
Add,
Edit
}
public openManageModal(type: ModalTypes) {
if (type == ModalTypes.Add) {
//Open edit modal
}
else {
//Open add modal
}
}
I cant seem to figure out how to call this from HTML. I have tried various things such as openManageModal('Add'), but nothing seems to work. Clearly I can create a function in the component, and parse the string to an enum, but I think this way would be more appropriate. Any help would be appreciated.
Thanks
You should be able to call the function like this:
openManageModal(0) // for ModalTypes.Add
openManageModal(1) // for ModalTypes.Edit
The enum declaration will transpile to the following by the TypeScript compiler:
var ModalTypes;
(function (ModalTypes) {
ModalTypes[ModalTypes["Add"] = 0] = "Add";
ModalTypes[ModalTypes["Edit"] = 1] = "Edit";
})(ModalTypes || (ModalTypes = {}));
So it basically creates an object which looks like this:
{
0: "Add",
1: "Edit",
Add: 0,
Edit: 1
}
So as you can see ModalTypes.Add == 0 and ModalTypes.Edit == 1.

set value of radcombobox from another combobox

set value of radcombobox2 from another radcombobox1
radcombobox2 is on asp usercontrol & radcombobox1 is on aspx page.
and value is coming from database on time of binding like this
if (result.IsSuccessful)
{
var rcbRadComboBox = (RadComboBox)RadGrid1.MasterTableView.FindControl("RadComboBox1");
if (comboEditAccessGroup != null)
{
comboEditAccessGroup.DataSource = result.Result;
comboEditAccessGroup.DataTextField = "Title";
comboEditAccessGroup.DataValueField = "JobId";
comboEditAccessGroup.DataBind();
}
}
but the problem is that ,i am not able to change selected index which is selected on radcombobox1
I have used
var selectedindexforjob = Request.QueryString["JobId"];
rcbRadComboBox.SelectedValue = selectedindexforjob;
for achieve goal but got failure nothing happens.
please help me.
Radcombobox1====is on aspx page
Radcombobox2=====is on ascx page
Thanks
Add a property to the user control:
public string ComboSelectedValue
{
get { return RadComboBox2.SelectedValue; }
set { RadComboBox2.SelectedValue = value; }
}
And then you can use this property from the page:
MyUserControl.ComboSelectedValue = RadComboBox1.SelectedValue;

Remove First Name, Last Name and confirm password fields in account create page

I searched a lot to remove required fields like first name, Last name and confirm passwordfields in account create page.
So far i renamed required value from 1 to 0 from the table eav_attribute
After this i hided first name, Last Name, Confirm Password from register.phtml
But still i'm getting
The first name cannot be empty, The Last name cannot be empty, etc,..
Did any one know how to do this ?
Please give me a idea to solve this..
You have to change two more files:
Change /js/prototype/validation.js and comment out the following lines:
['validate-cpassword', 'Please make sure your passwords match.', function(v) {
var conf = $('confirmation') ? $('confirmation') : $$('.validate-cpassword')[0];
var pass = false;
if ($('password')) {
pass = $('password');
}
var passwordElements = $$('.validate-password');
for (var i = 0; i < passwordElements.size(); i++) {
var passwordElement = passwordElements[i];
if (passwordElement.up('form').id == conf.up('form').id) {
pass = passwordElement;
}
}
if ($$('.validate-admin-password').size()) {
pass = $$('.validate-admin-password')[0];
}
return (pass.value == conf.value);
}],
After that, you also have to change the Magento Customer Core model. There are two types of validation: through the front-end javascript and in the backend Customer model.
Rewrite the model with your own customer module. Then copy the validate() public function. And comment out the following lines:
$confirmation = $this->getConfirmation();
if ($password != $confirmation) {
$errors[] = Mage::helper('customer')->__('Please make sure your passwords match.');
}

Resources