Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
446 views
Hello there,
I have a UserControl that i am trying to use as edit form for a RadGrid. The UserControl has some controls inside that perform postbacks (such as a RadComboBox changing the value of a RadNumericTextBox on SelectedIndexChanged), however I ajaxified this using a RadAjaxManagerProxy and adding the combobox as initiator and the same combobox and the textbox as updated controls.

In the NeedDataSource handler of the grid, i set the DataSource property with a collection of objects and in the ItemDataBound handler for the grid, if the item is in edit mode, i set some properties of the UserControl, including the one which stores the id of the object to be loaded.

This is the code for the two handlers:
protected void grdRelated_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    { 
        grdRelated.DataSource = GetGridDataSource(); 
    } 
 
protected void grdRelated_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem &&  e.Item.IsInEditMode) 
        { 
            IAssignControl ctrl = e.Item.FindControl(GridEditFormItem.EditFormUserControlID) as IAssignControl; 
            if (ctrl != null) 
            { 
                AssignedProduct assignedProduct = (e.Item as GridEditFormItem).DataItem as AssignedProduct; 
                ctrl.EntityType = "Opportunity"; 
                ctrl.BOId = "86cc5561-d769-4b77-b51e-386e989de0ae"; 
                ctrl.InAssignMode = false; 
                ctrl.AssignedProductID = assignedProduct.UniqueID; 
                ctrl.Refresh(); 
            } 
        } 
    } 

ctrl.Refresh() calls a method inside the UserControl which redraws the inner controls, as they are dynamically added to the UserControl.

When the edit button inside the grid is pressed, putting the row in edit mode, everything works ok and the UserControl is loaded properly. However, let's say i change the selection of a combobox inside the UserControl. As i said, this needs to update a textbox in the same user control according to the new selection. Though the combobox would normally trigger a postback and refresh the whole page, textbox included, as this is ajaxified using the RadAjaxManagerProxy defined inside the UserControl, i would expect only the textbox to be updated and no action performed on the other inner controls or the radgrid having this UserControl as edit form.

What actually happens is that somehow, the NeedDataSource event is fired again, reloading the grid data source, which then triggers a Rebind on the grid, which then goes into ItemDataBound, reassigns the UserControl properties and triggers the ctrl.Refresh() which redraws the inner controls. At this point, the inner controls are re-created according to the initial data, while the ViewState contains the modified data, leading to a mismatch between the saved state and the current state. Bingo, corrupted ViewState error.

What i don't understand is why an ajax request inside the UserControl leads to the containing grid firing its NeedDataSource event. The way I see it (please correct me if i am wrong with this), the ajax request should only update the controls specified in the RadAjaxManagerProxy settings, not the whole grid. Have i made any mistake in approaching this? If so please shed some light on this matter as I have no idea how to get past this.

While browsing the other forum threads, i came across THIS thread, which seems related, though i cannot say for sure it's the same problem i'm experiencing.
Veli
Telerik team
 answered on 05 Oct 2009
1 answer
102 views
I am trying to create a custom dialog. I first tried the example given here

http://demos.telerik.com/aspnet-ajax/editor/examples/customdialogs/defaultcs.aspx

and I got it working.

Then I swapped in my own aspx page and tried to hook it up in the same way. My aspx page is a frameset with 2 frames. The "submit" button is on the first frame. On this page I added the javascript to close the dialog and return a value. This is not working and the dialog stays open.

I traced the problem to the javascript function getRadWindow().

function getRadWindow()
  {
    if (window.radWindow)
    {
        return window.radWindow;
    }
    if (window.frameElement && window.frameElement.radWindow)
    {
        return window.frameElement.radWindow;
    }
    return null;
  }

It is returning null as both if statements resolve to false. I have dug around with Firebug to see if I can find a way to get the Rad Window but to no avail. Any ideas on how can I get this function to work when it is called in a frame in the dialog?

Rumen
Telerik team
 answered on 05 Oct 2009
2 answers
117 views
Hi

How can I bind the whole Container.DataItem to my Control in the FormTemplate? I have a UserControl for editing my object (in this case Person) and would like to reuse this in the EditFormSettings of the RadGrid but can't achieve this in a TwoWay mode. 

My code so far:
  <EditFormSettings> 
                <FormTemplate> 
                    <uc:GridButtons ID="GridButtons2" runat="server" Position="Top" />     
                        <data:PersonPanel runat="server" ID="PersonPanel" DataSource='<%# Container.DataItem %>' 
                            AddCss="panel" GroupingText="Personendaten"  />               
                    <uc:GridButtons ID="GridButtons1" runat="server" Position="Bottom" />       
                </FormTemplate> 
            </EditFormSettings> 

GridButtons is just a UserControl with the Edit/Canel buttons (top and bottom) whereas PersonPanel is my control which takes a Person object and gives a Person object back (DataSource Property). The Propblem is that the Container.DataItem expression is only OneWay, how could I achieve this in both ways so the RadGrid gets the updated Object back?

Thanks for help!
Softec
Top achievements
Rank 1
 answered on 05 Oct 2009
1 answer
107 views
I have been looking at the example of the RadGrid editing with a UserControl. I am not sure how to bind the values to the UserControl fields. Is this done automatically some how? How are the values passed across to to do the initial bind when the row is selected in the grid?

I notice that there is some code like this but I don't understand how it is getting used to do the binding:

public object DataItem 
        { 
            get 
            { 
                return this._dataItem; 
            } 
            set 
            { 
                this._dataItem = value; 
            } 
        } 

Veli
Telerik team
 answered on 05 Oct 2009
3 answers
124 views
I'm having a hard time understanding the demo of Load on Demand (http://demos.telerik.com/aspnet-ajax/tooltip/examples/loadondemand/defaultVB.aspx). Primarily, how the productid is passed into the UC. I see it on the manager.targetcontrols.add line in defaultvb.aspx.vb, but I'm failing to see how the UC gets that value. Is it the last 2 lines in UpdateToolTip sub? What is the function of those lines? If you could explain the process a little bit, it would be greatly appreciated!

Also, can you pass more than 1 thing from the tooltip into the UC?

Using version 2008.1.515.20
Nik
Top achievements
Rank 1
 answered on 05 Oct 2009
2 answers
128 views
hi,

Anyone know how to prevent automatic date recognition in datepicker even if i typed a wrong date.

thanks.
Benjamin
Top achievements
Rank 1
 answered on 05 Oct 2009
1 answer
262 views
Hi,

First let me say that I've seen this post at the following URL, and it won't do everything I need to do.

http://www.telerik.com/community/forums/aspnet-ajax/calendar/how-to-prevent-client-dateselected-from-being-fired.aspx

I have a RadDatePicker with a Calendar, and want to do the following:
 - Allow the user to change a date by editing the textbox of the RadDatePicker (and also via the calendar popup).
 - When they do change the date by editing the textbox of the RadDatePicker, I want to have a javascript function confirm that they really want to do this.
 - If they choose to Cancel, I want to reset the date in the RadDatePicker textbox back to its original value.

I can do all of that via a javascript function assigned to the OnDateSelected client side event.  But when I reset the date back to the original date using set_selectedDate, that of course causes the OnDateSelected event to fire again.  So in my case, I get another prompt asking them to confirm their actions.

Question:  How can I cancel the event before calling set_selectedDate, so the event doesn't fire again?
The workaround shown in the link above, does something in the popup opening event.  But that doesn't handle the case I'm talking about, where the user physically changes the date by typing in the textbox.

Thanks,
Brent
Dimo
Telerik team
 answered on 05 Oct 2009
2 answers
123 views
I am trying to create a SQL Server like interface where a row is always available for adding new entries to a table.  As you enter data for one of the columns it automatically adds a new blank row.  This is done to allow multiple rows to be added without having to hit the "add" button.  How do I accomplish this?

Thanks

DH
Danton Harrylal
Top achievements
Rank 1
 answered on 05 Oct 2009
7 answers
116 views
on your online sample, there is a bug

http://demos.telerik.com/aspnet-ajax/scheduler/examples/outlook2007/defaultcs.aspx

if you go to February 9, 2009 in the calendar and mouse over the day showing an appointment the appoinement dissapears on the calendar on  mouse over. I am experiencing the same thing on code based off of this sample. please help because this makes the feature kinda useless
Mira
Telerik team
 answered on 05 Oct 2009
3 answers
121 views
Can somebody please help with this as it's doing my head in! When I am editing an appointment in advanced edit mode, everything updates fine apart from the start date and time, for some reason this does not want to update, If I drag and drop the same appointment the start time updates no problem - any idea why this might be? I'm binding in the advanced edit template as follows;

<

 

telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" SelectedDate='<%# Bind("Start") %>' TimeView-EndTime="18:59:59" TimeView-StartTime="08:00:00" TimeView-Interval="00:30:00"  />

 

 

</telerik:RadDateTimePicker>

 

Peter
Telerik team
 answered on 05 Oct 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?