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

InitInsert

2 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
fatih ak
Top achievements
Rank 1
fatih ak asked on 29 Jul 2009, 12:07 PM
I am using a radgrid in my projet  When i click "Add new Record" button automaticly a new row creating . 2 colums has radnumerictextbox
and i want to make "0"  value of other radnumerictextbox  wheen i enter some value one of radnumerictextbox .

I accomplish it when i update a record  but i didnt do it when i insert a new recor ....
                        function onCommand(sender, args) 
                        {                                         
                                 if(args.get_commandName()== 'Edit')  
                                 {     
                                   currentRowIndex = args.get_commandArgument();  
                                   
                                 } 
                                                
                        }          
                                   
                        function onKeyPresstbBorc(sender, eventArgs) 
                        { 
                          alert(currentRowIndex); 
                          var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();  
                          var dataItem = masterTable.get_dataItems()[currentRowIndex]; 
                          var radTextBox1 = dataItem.findControl("tbAlacak"); 
                          radTextBox1.set_value(0.00); 
                        } 


 when i want to edit a record i use the above code and it work . but i dont know how can i do when i new record inserting  ????




 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Jul 2009, 01:34 PM
Hi,

One suggestion would be storing the client id of the textbox and then trace the textbox on the client  in order to set the second textbox value.

C#:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem) 
    { 
        GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item;  
        RadNumericTextBox txtBox = (RadNumericTextBox)insertedItem["NT2"].FindControl("RadNumericTextBox2"); 
        RadGrid1.Controls.Add(new LiteralControl("<script type='text/javascript'>window['BoxId'] = '" + txtBox.ClientID + "';</script>"));  
         
    }   

JavaScript:
 
<script type="text/javascript"
function onKeyPresstbBorc(sender, eventArgs)  
  var Name= $find(window['BoxId']); 
  var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();   
  var dataItem = masterTable.get_dataItems()[currentRowIndex];  
  var radTextBox1 = dataItem.findControl("tbAlacak");  
  Name.set_value(0.00);  
}  
</script> 

Shinu
0
fatih ak
Top achievements
Rank 1
answered on 29 Jul 2009, 02:16 PM
            if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem) 
            { 
                GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; 
                RadNumericTextBox txtBox = (RadNumericTextBox)insertedItem["NT2"].FindControl("tbAlacak"); 
                RadGrid1.Controls.Add(new LiteralControl("<script type='text/javascript'>window['BoxId'] = '" + txtBox.ClientID + "';</script>")); 
            }  

When i presss "Add New Record" it does not enter the code block above  ??
Tags
Grid
Asked by
fatih ak
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
fatih ak
Top achievements
Rank 1
Share this question
or