Telerik Forums
UI for ASP.NET AJAX Forum
9 answers
576 views

I’m trying to set up a call to an api method inside of some client side javascript.
The javascript function (GetDb) is called from the ClientEvents-OnValueChanged event of a RadMaskedTextBox

In that javascript function I set the url of a RadClientDataSource and do a fetch. To be honest I don’t completely understand how this works and how I can access the data using the RadClientDataSource after the fetch. My goal is to call the api through the javascript and get data back that I need to use.

As you can see in the RadClientDataSource, I have a dummy url which I replace in the Javascript function GetDb. I did this because if there was an empty url in the RadClientDataSource I was unable to set the dataSource._transport.read.url in the javascript. The url will have to be created dynamically in the long run (right now it’s hard coded) so I am changing the transport url in the javascript. Eventually the final parameter in the rest call in the url will have to be passed and will be variable.

From what I can see the a RadClientDataSource is not being activated and the api method is not being called. After the fetch I looked at the data source property and there were no rows

I set up the API by creating a Controllers folder in my project and then adding a scaffolded controller that uses Entity framework. This API controller inherits from APIController.

I tested the controller by running the function I want to use (GetMeasureByControlName) in fiddler and it worked.

Below is the code. I pieced this together from existing examples but there is none that do exactly what I want. I’d appreciate any help.

<telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" Width="80px" Mask="##.##" ClientEvents-OnValueChanged="GetDb" >  </telerik:RadMaskedTextBox>



<telerik:RadClientDataSource runat="server" ID="RadClientDataSource1">
    <DataSource>
        <WebServiceDataSourceSettings ServiceType="OData">
            <Select Url="localhost:53558/api/measure/GetProductById/blah" DataType="JSONP" />
        </WebServiceDataSourceSettings>
    </DataSource>
</telerik:RadClientDataSource>

I set a dummy url because unless there was something in there I couldn’t reset the transport url below in GetDb (javascript function).

 

Here is Clientside code called by the RadMaskedTextBox1 above:

function GetDb(sender, args) {
            debugger;
            var docTypeID='<%=Session["DocTypeId"]%>';
            if (args != null) {
                var value = args.get_newValue();
                var dataSource = $find("<%= RadClientDataSource1.ClientID%>");
                dataSource._transport.baseUrl = 'http://localhost:53558/api/documentmeasuretypes/';
                dataSource._transport.read.url = dataSource._transport.baseUrl + "GetMeasureByControlName/CYLINDER%20BLOCK%20HEIGHT";
                dataSource.fetch();
                var items = dataSource.view();
                var item = items[0];
                alert(item);
                alert('after fetch');
            }
        }

After the fetch the Total rows in the data source was 0.

The controller method does work; I tested it in fiddler. Here it is.
        public DocumentMeasureType GetMeasureByControlName(string controlname)
        {
            using (APIManufacturingEntitiesConsolidated db = new APIManufacturingEntitiesConsolidated())
            {
                var product = db.DocumentMeasureTypes.FirstOrDefault(m => m.MeasureName.Contains(controlname));
                if (product == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                return product;
            }
        }

 

And here is the routing:
  RouteTable.Routes.MapHttpRoute(
           name: "ActionApi",
           routeTemplate: "api/{controller}/{action}/{controlname}",
           defaults: new { id = RouteParameter.Optional }
);

            RouteTable.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = System.Web.Http.RouteParameter.Optional }




Eric R | Senior Technical Support Engineer
Telerik team
 answered on 27 Dec 2019
7 answers
156 views
We implemented the radhtml chart . We are showing the chart using iframe . In that iframe  we have a page redirection ,in that redirected page have binding methods and all . by the time chart is loading correctly but legend is overlapping in IE browser (IE-8 & IE-9) . Other browser that is chrome and firefox legend displayed correctly .Please see attached image for a visual explanation.

Parent page : 

      <div class="chartDiv" style="width: 730px; height: 620px;">
                                   <iframe src="ShowChart.aspx" frameborder="0" width="720px" height="585px" scrolling="no">
                                    </iframe>
                            </div>

child page : 

     <div>
                       <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                    </telerik:RadScriptManager>
                        <telerik:RadHtmlChart ID="BigHtmlChart" runat="server" Width="700px"  Height= "480px">
                            <PlotArea> 
                                <Series>
                                </Series>
                            </PlotArea>
                        </telerik:RadHtmlChart>
                    </div>
Rajesh
Top achievements
Rank 1
 answered on 27 Dec 2019
4 answers
161 views

I am trying to redirect to another page on process cancellation (triggered by cancel button).

My progress event is running on separate thread, here is the code:

Public Sub ProgressArea()

        Do
            Dim dt As DataTable = AdminData.getLogPercent(Session("ProjectID"))

            Dim count As Integer = dt.Rows(0)("PercentDone")
            Dim message As String = dt.Rows(0)("RecordDesc")

            context.SecondaryValue = "Total Progress: " & count.ToString() + "%"
            context.SecondaryPercent = count.ToString()
            context.CurrentOperationText = message

            If Response.IsClientConnected = False Then

                Response.Redirect("redirect.aspx")

            End If

            If count < 98 Then
                'calls to itself to repeat
                Thread.Sleep(1000)
            Else
                Exit Do
            End If

        Loop

    End Sub

Code hits the redirect , but nothing happens. However if i redirect without clicking "Cancel" button it does work.

I am completely lost. Any help?

Thank you

David
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 26 Dec 2019
10 answers
834 views

Hi,

I want integrate in my website the chatbot functionality, I found the component with the features that I need 

https://demos.telerik.com/aspnet-ajax/chat/overview/defaultcs.aspx

 

But for beginning you don't have some  tutorial about how integrate Google DialogFlow with this component?

If is done some tutorial will be great for evaluate the component and after decide if I purchase this package (asp.net UI ajax)

 

Thanks

Peter Milchev
Telerik team
 answered on 26 Dec 2019
3 answers
434 views
Hi,

I am working on the hierarchical radgrid and displaying data using code behind data binding, also  I am using  AllowKeyboardNavigation = "true" and AllowActiveRowCycle = "true" and <Selecting AllowRowSelect="true"> for the client settings of my RadGrid. My Grid is in an UpdatePannel.

My requirement is when my grid is refreshed then the selected row should be selected and the scroll bar position should be at the same  location but now when it is refreshing scroll bar is moved to the top of the grid at first and then it coms back to the selected position(flickering). this is happening when  I am clicking on the grid rows and also using the "UP ARROW" key to the radgrid.

could you please help me on the above requirement?

Thanks and Regards,
Eyup
Telerik team
 answered on 26 Dec 2019
4 answers
274 views

The version I use is 2015 Q2.  The ComboBox will display unnecessary vertical scroll bar in the dropdown list when "CheckBoxes" is used.

How to depress the vertical scroll bar when it's not needed?

 

        <telerik:RadComboBox ID="RadComboBox1" Runat="server" CheckBoxes="True">
            <Items>
                <telerik:RadComboBoxItem Text="Apple" Value="1" />
                <telerik:RadComboBoxItem Text="Banana" Value="2" />
                <telerik:RadComboBoxItem Text="Pear" Value="3" />
            </Items>
        </telerik:RadComboBox>

Peter Milchev
Telerik team
 answered on 25 Dec 2019
10 answers
760 views
When clicking on a GridCheckBoxColumn (The actual Check box) and the grid is in Batch Edit mode, the cell is not editable. You can click outside of the check box to make the cell editable but clicking on the check box does nothing. You can see this here in your own demo

http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

Can this be fixed? The other controls on the grid can be directly clicked to turn editable so its not intuitive at all for end users. 

Thanks
Eyup
Telerik team
 answered on 25 Dec 2019
3 answers
178 views

Using a radcombobox which allows typing. if you put the cursor in the textbox the Home?end keys do not work. In previous versions the Home/End key moves the cursor to the begin/end of the typed text. You can see this isn't working on your demo site https://demos.telerik.com/aspnet-ajax/combobox/examples/overview/defaultcs.aspx

This was working in version 2018.2.710.45 but broken in version 2019.3.917.45

Eyup
Telerik team
 answered on 25 Dec 2019
3 answers
242 views

Hello,

Currently we are using the below Telerik editor and we have a Div tag inside an anchor tag and noticed the when we switch from html to design it completely changes the html structure. Does Telerik have a fix for this issue since this is a valid html

https://demos.telerik.com/aspnet-ajax/editor/examples/overview/defaultcs.aspx

Expected HTML
<div class="image-container"><a href="~/media/9e240848ab264358a85b71a5ef739fbb.ashx?w=900" data-lightbox="9E240848-AB26-4358-A85B-71A5EF739FBB" name="AD7175-2-PR_9E240848-AB26-4358-A85B-71A5EF739FBB"></a><div class="icon-zoom"><a href="~/media/9e240848ab264358a85b71a5ef739fbb.ashx?w=900" data-lightbox="9E240848-AB26-4358-A85B-71A5EF739FBB" name="AD7175-2-PR_9E240848-AB26-4358-A85B-71A5EF739FBB"> test</a></div></div>

Telerik is change it to , as you notice it adds additional anchor tags

<div class="image-container"><a href="~/media/9e240848ab264358a85b71a5ef739fbb.ashx?w=900" data-lightbox="9E240848-AB26-4358-A85B-71A5EF739FBB" name="AD7175-2-PR_9E240848-AB26-4358-A85B-71A5EF739FBB">
</a>
<div class="icon-zoom"><a href="~/media/9e240848ab264358a85b71a5ef739fbb.ashx?w=900" data-lightbox="9E240848-AB26-4358-A85B-71A5EF739FBB" name="AD7175-2-PR_9E240848-AB26-4358-A85B-71A5EF739FBB"> test</a></div>
</div>

Please advise how this can be fixed.

Rumen
Telerik team
 answered on 23 Dec 2019
7 answers
448 views
Hi all I would like to show a pop up on cancel event of both insert and edit of radgrid. Means when ever user clicks on cancel I would like to show a popup saying are you sure you want to cancel if yes means I would like to cancel the update or insert. If no I would like to make insert and edit as it is can some one help me
Eyup
Telerik team
 answered on 23 Dec 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?