This is a migrated thread and some comments may be shown as answers.

[Solved] Get edit value on update command client side

1 Answer 225 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ron Trotto
Top achievements
Rank 1
Ron Trotto asked on 17 Apr 2009, 04:04 PM
We have a popup edit and have captured the update event client side to do a validation by way of a confirmation popup.  The issue is that we have a rad date picker in the popup and we cannot seem to figure out how to get the edit value.  Could some post an example of how to do this client side? 

All other mechanics are in place, we just need to know how to access the edit value,  we are capturing the command events by:

 

<ClientEvents OnCommand="RaiseCommand"/>

  

And we need to get our edited values from/in our client side script ....  we already have access to previous values (data values) but do not seem to be able to get the edited values

here is the latest of the test code to try to get this to work ...
 

 

 

 

function RaiseCommand(sender, args)

{

 

//retrieve the current commandName and commandArgument

 

 

 

 

var result = String.format("CommandName: {0}, CommandArgument: {1}", args.get_commandName(), args.get_commandArgument());

 

 

 

if(args.get_commandName() == "Update"){

 

 

 

var grid = sender;

 

 

 

var MasterTable = grid.get_masterTableView();

 

 

 

var row = MasterTable.get_dataItems()[args.get_commandArgument()];

 

 

 

var cell = MasterTable.getCellByColumnUniqueName(row, "EndDate");

 

 

 

var dtStart = new Date("<%=ViewState("StartDate").ToString %>");

 

 

 

var dtCompare = new Date();

 

 

 

var popUp = args.get_popUp();

 

 

 

var pArgs = popUp.arguments;

 

alert(pArgs.EndDate);

 

 

if(cell.innerHTML == "" || cell.innerHTML == "&nbsp;"){

 

 

dtCompare =

"01/01/1800"

 

 

 

else{

 

 

 dtCompare = cell.innerHTML;

}

alert(dtStart);

alert(dtCompare);

  

 

 

var newValues=MasterTable.extractValuesFromItem(args.get_commandArgument());

 

var newValuesSB = new Sys.StringBuilder();

 

 

 

for(var property in newValues)

 

 

{

newValuesSB.append(String.format(

 

 

"<b>{0}</b> : {1} <br/>", property,newValues[property]));

}

alert(newValuesSB);

 

if(dtCompare < dtStart){

 

 

 

// confirm

 

 

 

 

if(!confirm("Setting the End Date as you have will result in this disclosure falling outside of the Annual Review Period. Do you wish to proceed?")) {

 

 

args.set_cancel(

 

 

true);

}

}

 

//alert(result);

 

 

 

 

}

 

 

}

 

 

Many many thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 22 Apr 2009, 07:53 AM
Hi Ron Trotto,

In order to achieve this scenario, take the following steps:

1. Attach an event handler to the OnPopUpShowing client event of the grid:

                <ClientSettings> 
                    <ClientEvents OnCommand="RasiseCommand" OnPopUpShowing="PopUpShow" /> 
                </ClientSettings> 

2. In the event handler of the letter store the html element of the popup form in a global variable:

                    var popUpElement;  
 
                    function PopUpShow(sender, args)  
                    {  
                        popUpElement = args.get_popUp();  
                    } 

3. In the OnCommand event handler get the value of the date picker (assuming its server ID is EndDatePicker) as follows:

                    function RasiseCommand(sender, args)  
                    {  
                        if (args.get_commandName()=="Update")  
                        {  
                            var endDate = $telerik.findElement(popUpElement,"EndDatePicker").value;  
                        }                        
                    } 

I hope this information helps.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Ron Trotto
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or