Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
39 views
Hi,

I'm using a rad grid to display invoice items. The first column of the grid is a drop down menu which gives the option to select an item. Once the item is selected the remaining columns will auto populate with price , quantity, amount, etc. Once the amount column populates . I execute a function (OnValueChanged event) to save that row of data with ajax web method. The problem occurs after the first row of data saves. If you immediately move to the second row and select an item sometimes it saves and sometimes it doesn't. If I wait about a minute to select an item in another row it will work but that's not ideal. It always works if I place a breakpoint or an alert in the function. I think it maybe an ajax issue BTW it works perfectly in IE.  Would appreciate any help. I've attached a screen shot of the grid and the code.

function AmountChanged(sender, args) {
 
          if (args._oldValue != '') {
 
              CalculateGridLineTotals();
              ReCalculateTaxes();                  
          }
          console.log("Row Number " + rowIndex1)
          SaveInvoiceItems();
       
      }
function SaveInvoiceItems() {

                var masterTable = $find("<%=grdInvoiceItems.ClientID%>").get_masterTableView();
                //for (var row = 0; row < masterTable.get_dataItems().length; row++) {
                var Id = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[rowIndex1], "Id");

                var grid = $find("<%=grdInvoiceItems.ClientID%>");
                var masterTbl = grid.get_masterTableView();
                var gridRow = masterTbl.get_dataItems()[rowIndex1];

                var item = gridRow.findControl("ddlItems")._text;
                var description = gridRow.findControl("txtDescription")._text;
                var price = gridRow.findControl("txtPrice")._text;
                var qty = gridRow.findControl("txtQty")._text;
                var discount = gridRow.findControl("txtDiscount")._text;
                var amount = gridRow.findControl("lblAmount")._text;

                if (discount == '')
                    discount = 0;
                if (price == '')
                    price = 0;
                if (qty == '')
                    qty = 0;
                if (amount == '')
                    amount = 0;

                var obj_as_object = { id: Id.innerHTML, item: item, description: description, price: price, qty: qty, discount: discount, amount: amount };;
                var obj_as_string = JSON.stringify(obj_as_object);

                var xhr = $.ajax({
                    type: "POST",
                    url: "/WebService/InvoiceWebService.asmx/UpdateRecurringInvoiceItems",
                    data: obj_as_string,
                    'async': false,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    beforeSend: function (xhr, settings) {
                        xhr.startTime = new Date().getTime();
                        $("#wait").css("display", "block");
                    },
                    complete: function (xhr) {
                        var elapsed = new Date().getTime() - xhr.startTime;
                        if (elapsed < 3000) {
                            $("#wait").css("display", "block").delay(7000 - elapsed).hide(1);
                        } else {
                            $("#wait").css("display", "block").hide();
                        }
                    }
                });

                //)).then(function (data, textStatus, jqXHR) {
                //    //alert("what is this"); // Alerts 200
                //});



                //setTimeout(doSomething(Id.innerHTML), 3000);
                //}

            }
   

thanks,
Ron.
Viktor Tachev
Telerik team
 answered on 27 Jan 2014
1 answer
112 views
Hi, I am putting together a website using some pages with telerik controls on them and then also the Blogengine.net open source system.  When I try and use the RadBinaryImage control on a page which inherits from a masterpage it doesn't show any of the images in a configured folder (like the demo).  Instead it shows the broken image icon.

What could I be doing wrong?  I have a zip file with a small project but can't attach it to this thread -

any ideas?

Many thanks

Alan
Shinu
Top achievements
Rank 2
 answered on 27 Jan 2014
2 answers
117 views
I want Root node , child node only  selected value's individual [ with out array format & check box] of Rad drop down tree  server said code
Kate
Telerik team
 answered on 27 Jan 2014
1 answer
45 views

When using a template for group headers, how does one catch the events (server side) triggered by a control therein?


basically I want to be able to click a groupheader and call a procedure to open radwindow.  This is easy to do on grid rows, but haven't found a way to do in group headers other than to add a control to it.    There seems to be two ways, programmatically add all controls (no template) or define a control(s) in a groupheader template.  However I can't seem to trap the events when using a template.



Is there a method I am over looking or Is there a way to add a eventhandler after the control is created?  Thanks.

Eyup
Telerik team
 answered on 27 Jan 2014
4 answers
202 views
Hi,
I am working for  Script injection in my project. suppose user enter some script in comment box which is free text (<script  type="text/javascript">alert('Hi')</script>). 
I used Server.HTMLEncode/HTMLDecode method to save in DB and show in text box respectively. But when I show in RadGrid with item template and Label control. It show alert instead of as text. Its working fine with simple textbox control but perhaps, issue with controls inside grid. One more thing I don't want to use ValidateRequest = false; any how as it may restrict to save such text.

Sample code I am using for Grid. I also tried in code behind with itemdatabound event of grid to bind Label.
<ItemTemplate>
        <asp:Label ID="lblComments" runat="server"   Text='<%#Server.HtmlDecode(Eval("Comments").ToString())%>' />
</ItemTemplate>

Any suggestion???? Is there any property/Method of Grid to resolve this issue.
Thanks in advance.
Sanjeev
Top achievements
Rank 1
 answered on 27 Jan 2014
5 answers
143 views
 When I enable the option to display "ALL" records int he grid, it is working. But when I add one more item with the ALL option selected, it throws an error.
Following code is my workaround. With this code, with ALL selected, when I add a new item, it goes to the second page, though all items shouls fit in the first page itself ( I have less than 50 items).

protected

 

 

void rgProjects_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)

 

{


 

 

if (e.Item is GridPagerItem)

 

{

 

 

var dropDown = (RadComboBox)e.Item.FindControl("PageSizeComboBox");

 

 

 

var totalCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;

 

 

 

bool ALLSelected = (dropDown.SelectedItem.Text == "ALL") ? true : false;

 

 

 

var sizes = new Dictionary<string, string>()

 

{

{

 

"50", "50"},

 

{

 

"100", "100"},

 

{

 

"200", "200"}

 

};

sizes.Add(

 

"All", totalCount.ToString());

 

dropDown.Items.Clear();

 

 

foreach (var size in sizes)

 

{

 

 

var cboItem = new RadComboBoxItem()

 

{

Text = size.Key,

Value = size.Value

};

cboItem.Attributes.Add(

 

"ownerTableViewId", e.Item.OwnerTableView.ClientID);

 

dropDown.Items.Add(cboItem);

}

 

 

try

 

{

 

 

if (ALLSelected)

 

dropDown.FindItemByValue(totalCount.ToString()).Selected =

 

true;

 

 

 

else

 

{

 

 

RadComboBoxItem item = dropDown.FindItemByValue(rgProjects.PageSize.ToString());

 

 

 

if (item != null) item.Selected = true;

 

}

}

 

 

catch (Exception ex)

 

{

ShowValidationMessage(ex.Message);

}

}
}

Viktor Tachev
Telerik team
 answered on 27 Jan 2014
1 answer
328 views
I have a web service that I want to return 2 values   and ID and a text value hrough and autocompletebox.  I have it working to return the service but now I need to get at the ID value that was returned, not the text value.  I would like to be able to do an Autopostback on the autocompletebox and hit a database with the ID to return more data to the page.  Is this possible iwht the autocompletebox as I have not been able to find code that shows this.  It would be similar to the asp Autocomplete extender that can return 2 values that you can then use.  Can I do this with a telerik AutocompleteBox.


<telerik:radautocompletebox ID="rdSearch" runat="server" EmptyMessage="Type Last Name First Name" EnableAutoComplete="true" MinFilterLength="2" MaxResultCount="20" Width="260px"
                                   DropDownHeight="100px" DropDownWidth="250px" DropDownPosition="static" AutoPostBack="true" OnClientEntryAdded="requesting">
                                    <TextSettings SelectionMode="Single" />
                                    <WebServiceSettings Path="../AutoComplete.asmx" Method="GetNames" />
                                </telerik:radautocompletebox>
 
 
  function requesting(sender, eventArgs) {
            var context = eventArgs.get_context();
            //Data passed to the service.
           // context["ClientData"] = "ClientData_Passed_To_The_Service";
        }
 
 
 [WebMethod]
    public AutoCompleteBoxData GetNames(RadAutoCompleteContext context)
    {
        string sql = "select intPersonnelId, strFullname FullName FROM tblMNNatPersonnel WHERE strFullname like '" + context.Text + "%'";
        //SqlDataAdapter adapter = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
         
        DataTable myDataTable = new DataTable();
        myDataTable = c.GetReader(sql);
 
        List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();
        AutoCompleteBoxData dropDownData = new AutoCompleteBoxData();
 
        result = new List<AutoCompleteBoxItemData>();
 
        for (int i = 0; i < myDataTable.Rows.Count; i++)
        {
            AutoCompleteBoxItemData itemData = new AutoCompleteBoxItemData();
            itemData.Text = myDataTable.Rows[i]["FullName"].ToString();
            itemData.Value = myDataTable.Rows[i]["intPersonnelId"].ToString();
 
            result.Add(itemData);
        }
 
        dropDownData.Items = result.ToArray();
        return dropDownData;
    }
 
When it returns to the autocomplete box I need to do take the intPersonnelId and hit a database and return more information.


Kate
Telerik team
 answered on 27 Jan 2014
8 answers
1.1K+ views
How do I disable the enter key rebind on RadGrid? I can't find a setting to either make the entire table read only, or just disable the enter key.

AllowKeyboardNavigation = "false" and <KeyboardNavigationSettings EnableKeyboardShortcuts="false" AllowSubmitOnEnter="false" /> do not disable the enter key. There is no need for this functionality to be permanently on. Rebinding 10,000 rows because someone accidentally hit enter is not a valid option.

Programming this via javascript seems hokey and cheap as a workaround, but if that's my only option... 

Please assist.

Regards,
~Owen



Konstantin Dikov
Telerik team
 answered on 27 Jan 2014
3 answers
109 views
Hello,
i've got an issue ralated to RadComboBox. When I use it without checkboxes it seems that all is ok: [look at comboissue1.png]
Unfortunately after switching to CheckBoxes dropdown choose to render in down direction and sets height that is to big to fit window.
[look at comboissue2.png]. 
I set a breakpoint on OnClientDropDownOpened and at that moment DropDown's height and directon are ok [look at comboissue3.png]. I don't know what spoils it after. 

.


Nencho
Telerik team
 answered on 27 Jan 2014
2 answers
77 views
Hi,
Is this normal that when I have two ListBoxes and one of them is empty the second one is populated with items, I can't drop any items into the empty one?
I'm seeing such behavior and don't know why this is happening.
Shinu
Top achievements
Rank 2
 answered on 27 Jan 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?