Disabled Kendo DropDownList in Javascript - javascript

Hi I'm trying to accomplished to disabled the KendoDropDownList via javascript.
I already did it but my problem is when I try to populate the KendoGrid the KendoDropDownList is disabled but the value is gone. Anyone know how to fix this? or Anyone know other way to do accomplished this ?
Heres my code:
<script>
$(document).ready(function () {
var url = "#Url.Action("CheckUserStatus", "Maintenance")";
var checkData = "CheckUser";
$.post(url, checkData, function (d) {
if (d != 0) {
// alert(d);
$("#office_id").data("kendoDropDownList").value(d);
document.getElementById("mode-status").innerHTML = "Update Program";
document.getElementById("button-status").innerHTML = "Update Program";
$("#grd_ApprovedBudget").data("kendoGrid").dataSource.read();
$("#office_id").kendoDropDownList({
enable: false
});
}
//alert(d);
})
});
</script>

When you call $("#office_id").kendoDropDownList, it will try to create a new instance of kendoDropDownList. If you want to disable an existing kendoDropDownList, you'll have to do it using the enable function of the existing instance:
$("#office_id").data("kendoDropDownList").enable(false);
Here's kendo documentation about the enable function.

Related

How can i insert value to textarea from variable using attr()

i am new to jQuery and i'm having a little problem i cant solve.
i tried to find a solution on google but with no success.
i want to insert value to textarea as a variable.
its inserting "facebook", instead of "hhhh".
$(".button").click(function () {
var facebook = "hhhh";
$('#htmlcode').val($(this).attr('id'));
return false;
});
jsfiddle:
http://jsfiddle.net/nv9xmzoq/4/
edit:
i have two buttons and i want to change the value according to their id
Just pass facebook variable to .val method, like this
$(".button").click(function () {
var facebook = "hhhh";
$('#htmlcode').val(facebook);
return false;
});
Example
If you need set id also, you can do like this,
$(".button").click(function () {
var facebook = "hhhh";
$(this).attr('id', facebook);
$('#htmlcode').val(facebook);
return false;
});
Example
Update
$(".button").click(function () {
var data = {
facebook: "hhhh",
twitter: "aaaa"
};
$('#htmlcode').val(data[$(this).attr('id')]);
return false;
});
Example
use to insert content
$('#htmlcode').val("something");
use to add atribute. ex:
$('#htmlcode').attr("disabled","disabled");
use to add or modify css
$('#htmlcode').css("width","500px");

How to disable and enable all the buttons with same class present on form on AJAX function call in following scenario?

I've multiple buttons with same class called "normalbtn". If user clicks on any one of these button AJAX function is called. I want to disable all the other buttons having class "normalbtn" disbaled while the AJAX request processes.
When the success response comes from the request all the buttons with class "normalbtn" should get enabled.
How should I achieve this by making necessary change in following function code?
function change_value(data_url, op, id, value) {
var data_value = value;
$.post(data_url, {'op':op, 'id':id, 'value':data_status }, function(data) {
if(data_value=='0') {
var value = '1';
$('#data_value_'+id+' button').text("On");
} else {
var value = '0';
$('#data_value_'+id+' button').text("Off");
}
$('#data_value_'+id).attr('onClick', "change_value('"+data_url+"', '"+op+"', '"+id+"', '"+value+"');return false;");
});
}
Thanks in advance.
Disable it before the post and enable back on success.
$('.normalbtn').prop('disabled', true);
$.post(data_url, {'op':op, 'id':id, 'value':data_status }, function(data) {
/// on success
$('.normalbtn').prop('disabled', false);
});
EDIT:
instead of attr('onClick') way, try using the 'data' attribute http://api.jquery.com/data/

Enable Disable Controls in kendo ui grid popup form

I use a grid with popup editor for insert and edit grid rows.
in template I use radio button group
and the properties defined in viewmodel
var viewModel = kendo.observable({
ChequeNaghdiChange:false,
ChequeReturnedChange:false
........
the NRDisabled is used for disable and enable control and its work perfectly out of popup by simple set true or false property
viewModel.set("ChequeNaghdiChange",false);
kendo.data.binders.NRDisabled = kendo.data.Binder.extend({
refresh: function () {
if (this.bindings.NRDisabled.get()) {
this.element.setAttribute("disabled", "disabled");
} else {
this.element.removeAttribute("disabled");
}
}
});
It's seems property binding have some problem in kendo.
Best Regards
Amir
I can say that I enable and disable controls in the popup a different way, I attach an event to the grids edit event as follows.
.Events(events => events.Edit("onOrderDesignGridEdit"))
Then in the edit function I setup the controls that I want enabled or disabled using the model.
function onOrderDesignGridEdit(e, a) {
var model = e.model;
var overrideTotal = model.OverrideTotal;
var totalEditor = $("#Total").data("kendoNumericTextBox");
totalEditor.enable(overrideTotal);
}

How to refresh a GridView in Extjs?

I am using a gridview which is binding data from datastore dynamically.
I have two textbox to enter data into grid.
On submit button click the textbox data I am adding to my datastore (no need to store in backend).
Now I want to refresh my gridview with datastore.
My Code:
_createEmptyRecord: function () {
var emptyrecord = Ext.data.Record.create(["id", "name", "type"]);
return new emptyrecord({
formula_id: 1,
name: Amit,
type: anything
});
},
_addValuetogrid: function () {
var record = this._createEmptyRecord();
this._store.insert(0, record);
},
_refreshgrid: function()
{
this._grid._addValuetogrid();
},
Now how to refresh my Gridview ?
Please help me...
Ext.grid.GridView has refresh() method.
this._grid.getView().refresh();
I believe a refresh function similar to this (untested) will work for Extjs 4;
_refreshgrid: function()
{
this._grid.getActiveView().refresh(true);
}

Populating a FilteringSelect datastore from an onChange event

I'm trying to bind an onChange event of one FilteringSelect to populate another FilteringSelect.
// View
dojo.addOnLoad(function () {
dojo.connect(dijit.byId('filterselect1'), 'onChange', function () {
dijit.byId('filterselect2').store = new dojo.data.ItemFileReadStore(
{ url: "/test/autocomplete/id/" + dijit.byId("filterselect1").value }
);
});
});
The JSON is generated from what I can tell correctly from a Zend Action Controller using a autoCompleteDojo helper.
// Action Controller
public function autocompleteAction()
{
$id = $this->getRequest()->getParam('id');
$select = $this->_table->select()
->from($this->_table, array('id','description'))
->where('id=?',$id);
$data = new Zend_Dojo_Data('id', $this->_table->fetchAll($select)->toArray(), 'description');
$this->_helper->autoCompleteDojo($data);
}
I receive the JSON from the remote datastore correctly, but it does not populate the second FilteringSelect. Is there something else I need to do to push the JSON onto the FilteringSelect?
I couldn't believe this was causing the problem, but the whole issue boiled down to the fact that it appears that a dojo ItemFileReadStore REQUIRES the label property of the JSON to be "name". In the end this is all that it required to wire them together.
dojo.addOnLoad(function () {
dijit.byId('filtering_select_2').store = new dojo.data.ItemFileReadStore({url: '/site/url'});
dojo.connect(dijit.byId('filtering_select_1'), 'onChange', function (val) {
dijit.byId('filtering_select_2').query.property_1 = val || "*";
});
});
UPDATE: The property within Zend form has been fixed as of ZF 1.8.4
Try console.log() in the event to see if it is launched. Changing the store should work, however for other widgets like grid you have also to call refreshing methods.

Categories