get_selectedItem().get_value() Not Working for RadComboBox - telerik

I use following code to try to get current selected value of a Telerik RadComboBox:
var combobox = $find("<%= cboBoxA.ClientID %>");
var txt = combobox.get_selectedItem().get_value();
But I get following JavaScript error:
Error: Object doesn't support property or method 'get_value'
What is the problem ? Thanks.

the following code worked for me:
var combobox = $find("<%= cboBoxA.ClientID %>");
var txt = combobox.get_text();

var combo = $find('<%=cboBoxA.ClientID %>');
alert(combo.get_selectedItem().get_value());
Refer to these links
https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/client-side-programming/overview
https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/client-side-programming/objects/radcombobox-object
https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/client-side-programming/objects/radcomboboxitemcollection-object

Related

Kendo UI Fails to Bind ViewModel

I’m not sure just how much detail I can provide or how much is necessary here, but-
I’m trying to upgrade an application from Kendo UI v2015.1.429 to v2019.1.220. However, it is failing when I try to bind a particular viewmodel to an element, throwing Uncaught TypeError: Cannot read property 'length' of undefined.
I’ve managed to track what I believe is the cause of this bug to the inferSelect function, in the code below. However, as far as I can tell, everything involved is or should be defined and this error should not be happening. It's working perfectly fine for a viewmodel on another page, and it works if I remove one specific element that I'm trying to bind the viewmodel to, but I can't find any reason for that element to fail.
What further information should I provide/investigate to fix this?
function inferSelect(select, fields) {
select = $(select)[0];
var options = select.options;
var firstField = fields[0];
var secondField = fields[1];
var data = [];
var idx, length;
var optgroup;
var option;
var record;
var value;
for (idx = 0, length = options.length; idx < length; idx++) {
--> record = {}; //The error is thrown on this line
...........
PROBLEM SOLVED. I was trying to bind a multiselect widget to an <input> rather than to an actual <select>. Thanks Kendo for giving such an informative error message.

Kendo grid's Select command operation configuration

Among Edit and Destroy, Kendo grid has a Select command too. But it seems there's no configuration for this operation. Do you know how can I use it? Any better way of JS binding like custom commands? Notice that it doesn't have a click event.
This line is in my Kendo grid, columns section.
columns.Command(command => { command.Select(); command.Edit(); command.Destroy(); });
Well, I found no better way than using a custom command.
Custom command inside grid:
command.Custom("select").Text("Select").Click("select");
and JS handler code:
<script>
function select(e) {
var grid = $("#grid").data("kendoGrid");
var item = grid.dataItem(grid.select());
var data = item.Title;
alert(data);
}
</script>
Another way to call this will be:
function select(e){
var row = $(e.currentTarget).closest("tr");
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
alert(dataItem.Title);
}

jqGrid getData from all page

I need to getdata from all pages in jqgrid
for which below code dont work
var allRowsInGrid = $('#grid').jqGrid('getRowData');
so tried this:
var allRowsInGrid = $("#grid").jqGrid('getGridParam', 'data');
which is working fine but all new data like edit done on any editable field is getting lost
i saw below link for similar issue
http://stackoverflow.com/questions/3307189/jqgrid-getdata-only-returns-data-for-current-page
please help

In CKEditor getSelection() returns null value in IE

I am having an small code to select an text in CKEditor. For that i am using following code in javascript.
var docx = editor.document;
var elementx = docx.getById(id);
editor.getSelection().selectElement(elementx);
editor.getSelection().scrollIntoView(true);
It works fine in Mozilla Firefox.But in IE9 it throws an error as selectElement is not an object. So i checked the code and found that getSelection() having an null value. Please help me how to solve it.
I tried some answers given in various sites even in CKEditor fourms nothing helped me.
That's the correct solution:
var editor = CKEDITOR.instances.editor1;
editor.focus(); // Without this selection will be null on IE.
var element = editor.document.getBody().getLast(),
selection = editor.getSelection();
selection.selectElement(element); // You have to reuse selection.
selection.scrollIntoView();
I tested this from the console on Firefox, Chrome and IE8 on http://ckeditor.com/demo and it worked.
This might work.
var docx = editor.document;
var elementx = docx.getById(id);
var resRange = new CKEDITOR.dom.range( editor.document );
resRange.selectNodeContents( elementx );
resRange.collapse();
editor.getSelection().selectRanges( [ resRange ] );
resRange.endContainer.$.scrollIntoView();
This may have something to do with what IE9 considers to be an object. Have you tried selecting different element types?
Maybe grabbing the parent of the element will give you something that IE9 considers to be an object, you can try this:
var docx = editor.document;
var elementx = docx.getById(id);
var parentx = elementx.getParent();
parentx.scrollIntoView();

get value from telerik combobox clientside

I have added a rad combobox to a page and need to be able to get the selected value from it. I can see below the html element a hidden field called 'mycontrol_ClientState' I take it this is where I am meant to retrieve the value from however I dont know how to.
Does anyone have an example of getting the value out clientside?
Use the get_value() JavaScript method:
var combobox = $find("<%= RadComboBox1.ClientID %>");
var value = combobox.get_value();

Resources