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

Validate field outside from grid

3 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kien Lim
Top achievements
Rank 1
Kien Lim asked on 01 Apr 2011, 09:36 AM
I need some help for the scenario below:

I have a telerik grid with GridTemplateColumn. This GridTemplateColumn contains telerik combox called "radTravelType" in the EditItemTemplate. This combobox has 3 RadComboBoxItem which are "Taxi", "Car" and "Public Transport". When I select "car" option, a field called "Vehicle No." should be validated(cannot be empty). however this vehicle no. field is not a field within the grid. How can I achieve this?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Apr 2011, 11:42 AM
Hello,

I am not quite sure about your aspx and I assume that  the ComboBox is inside EditItemTemplate and the VehicleNo is a TextBox which should not be empty if the ComboBox selected item is car and you want to validate when submitting the page.

If that is the case, there are many approaches to achieve the same. One approach is to use the CustomValidator and declare a global variable say "flag" .Attach the OnClientSelectedIndexChanged event to the ComboBox and set the flag value if the ComboBox selected item is "car".

Javascript:
var flag=0;
function
OnClientSelectedIndexChanged(sender, args)
{
if(args.get_item().get_text()=="car")
{
flag=1//set the flag value
}
}
function ClientValidationFunction(sender,args)
{
//checks for the flag value
   if(flag==1)
   {
     //access the text box and set the args.IsValid accordingly.
    }
}

Thanks,
Shinu.
0
Kien Lim
Top achievements
Rank 1
answered on 05 Apr 2011, 02:13 AM
Hi Shinu,

Thanks for your help, I opt for Custom validator and validate at code-behind. It is working fine as well.

I was also looking for some client -side calculation in grid cell. For example: when I key in price per unit and quantity in edititemtemplate, it should calculate the total within the grid. Can you show me some sample code?

Many thanks
0
Tsvetina
Telerik team
answered on 08 Apr 2011, 08:11 AM
Hello Kien Lim,

You can try modifying the approach demonstrated in the following help article in order to fit your needs:
RadNumericTextBox for Footer Totals

Greetings,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Kien Lim
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kien Lim
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or