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

[Solved] Problem in SelectRow in client and ComboBox CehckBox

3 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jose
Top achievements
Rank 1
Jose asked on 09 Mar 2013, 04:07 PM

Good morning.

I have a form of low Additions and changes, in which data is stored in a DB, to consult on a GRID shown in this way I have a RadComboBox with opchion of CheckedBox, the start page is read the first record in the grid , which puts on the combo records check (this is in the gRID rowselected the client side) and is correct, but when clicking on another grid record, this does not mark that must be left with the same selection of combos.

Schedule the code, the GRID and RowSelected the generating function to mark records, thanks in advance for your support.

functionRowSelected(sender, eventArgs) {

 var comboPais = $find('<%=RCbo_int_pkpaicvepais.ClientID%>');

 var comboEstado = $find('<%=RCbMs_Var_pbcCveEstados.ClientID%>');

 if ($get('<%= Txt_TipoMovimiento.ClientID %>').value == 'N' ||  $get('<%= Txt_TipoMovimiento.ClientID %>').value == 'M')

 { } else

 { $find('RTxt_int_pkemempresa').set_value(eventArgs.getDataKeyValue("int_pkemempresa"));

 $find('RTxt_Int_PKpbcCveTabla').set_value(eventArgs.getDataKeyValue("Int_PKpbcCveTabla"));

 $find('RCbo_int_pkpaicvepais').set_text(eventArgs.getDataKeyValue("int_pkpaicvepais"));

 $find('RCbMc_int_pkmuncvemunicipio').set_text(eventArgs.getDataKeyValue("int_pkmuncvemunicipio"));

 $find('RCbMc_Int_pbcCvePrecio').set_value(eventArgs.getDataKeyValue("Int_pbcCvePrecio"));

 $find('RCbo_Int_pbcCveTienda').set_value(eventArgs.getDataKeyValue("Int_pbcCveTienda"));

 $find('RTxt_Tyint_pbcEstatus').set_value(eventArgs.getDataKeyValue("Tyint_pbcEstatus"));
//Eject function CkeckItems

 EnableItems($find("<%= RCbMs_Var_pbcCveEstados.ClientID %>"), eventArgs.getDataKeyValue("Var_pbcCveEstados"), false);
EnableItems($find("<%= RCbMs_Var_pbcCvesProductos.ClientID %>"), eventArgs.getDataKeyValue("Var_pbcCvesProductos"), true);

 }

 

 } 

 

function EnableItems(combo, Str_Elementos, Bol_Estatus) {

 var comboItems = combo.get_itemData();

 var comboDatos = combo.get_items();

 if(Str_Elementos.trim() != "")

 {
var Str_ArrElem = Str_Elementos.split(",");
//Clear ItemsChecks

 Fn_MarcaDesmarcaChecks(combo, Bol_Estatus);

 

combo.trackChanges();

 

for (var j = 0; j < Str_ArrElem.length; j++) {

    for (var i = 0; i < combo.get_items().get_count(); i++) {

       if (comboItems[i].value == Str_ArrElem[j].trim()) {

       //alert(comboDatos._array[i]._text + "-" + i + "-" + Str_ArrElem[j].trim() + "-" + comboItems[i].value);

       comboDatos._array[i].set_checked(true);
       break;

     }

   }

}

}

combo.commitChanges();

}

 

 

function Fn_MarcaDesmarcaChecks(combo, Bol_Marca) {
var comboDatos = combo.get_items();

 combo.trackChanges(); 

for (var i = 0; i < combo.get_items().get_count(); i++) {

 comboDatos._array[i].set_checked(Bol_Marca);

 

 } 

combo.commitChanges();

 }

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 14 Mar 2013, 07:25 AM
Hello,

 The provided code looks OK. You can check whether the RowSelected event is properly fired every time and that it passes the correct data key values. Also for checking of items in the combo it is recommended to get a current item from the collection using the getItem method instead of the private _array property.More information on the feature can also be found in the following demos:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/checkboxes/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/client/selecting/defaultcs.aspx

All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jose
Top achievements
Rank 1
answered on 14 Mar 2013, 06:10 PM

Greetings.

As I commented, test and put a ALERT to validate that bring the correct data, and does, go through what I have selected items, but when viewing the data appear combo loaded the first time to load screen (in LOAD), try to exhaust all resources to come to you, and searched the Internet and can not find anything like this.

for (var j = 0; j < Str_ArrElem.length; j++) {

for (var i = 0; i < combo.get_items().get_count(); i++) {

if (comboItems[i].value == Str_ArrElem[j].trim()) {

//alert(comboDatos._array[i]._text + "-" + i + "-" + Str_ArrElem[j].trim() + "-" + comboItems[i].value);

comboDatos._array[i].set_checked(true);
break;

}

}

Please could you give me an example to use instead of _Array getitem.

THE ROWSELECTED it takes to assign values ​​to dates, to Textbox and have had no problems, fills smoothly, so I guess it must be some trick of the component.

These components occupying them in another company, you actually have commented that they are very good, but they asked me to show them something with the GRID and COMBO checkboxes, but I have stuck, and I depend on it to get convince to buy them, I hope I can supporting.

The image shows the selection in the GRID and the data selected in the Combo are the first record were loaded on page load, and not the selected record.

Thank you.

0
Marin
Telerik team
answered on 19 Mar 2013, 11:59 AM
Hi,

 You can find attached a sample page which demonstrates how to change the checked items in the combo on RowSelected event in the grid. Basically you need to iterate over the combo items and use their set_checked method to check the needed ones.

All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jose
Top achievements
Rank 1
Answers by
Marin
Telerik team
Jose
Top achievements
Rank 1
Share this question
or