Navigation: DbNetComboCore >

Events

 

 

 

 

 

Events are used to call client-side JavaScript methods in response to a client-side grid event (EventType) which enables additonal levels of customisation. The event passes 2 arguments to the client-side method. The first is a reference to the client-side grid control and the second (optional) argument is an object that contains information specific to the event type.

 

OnInitialized

 

This event is fired as soon as the client-side instance of the grid has initialised and can be used to save a client-side reference to the grid control if needed.

 

OnOptionsLoaded

 

This event is fired after the combo options are loaded. The args parameter has a single property of options which is an array of all the HTMLOptionElement objects that have been loaded

 

...

var customersCombo = new DbNetComboCore("northwind", "customers", "customerid", "companyname", "filteredcustomers") { AddFilter = true };

customersCombo.Bind(EventType.OnOptionsLoaded, "showNumberOfOptionsLoaded");

@customersCombo.Render();

...

<script type="text/javascript" class="source">

function showNumberOfOptionsLoaded(control, args) {

    $("#optionsLoaded").html(`${args.options.length} options loaded`);

}

</script>

...

 

OnOptionSelected

 

This event is fired after an option in the combo box is selected. The args parameter has a two propertes. The first being selectedValues which is an array of the values of the selected options and the second is selectedOptions which is an array of the selected HTMLOptionElement objects that have been selected

 

...

DbNetComboCore customersCombo = new DbNetComboCore("northwind", "customers", "customerid", "companyname");

customersCombo.Bind(EventType.OnOptionSelected, "showSelectedCustomer");

@customersCombo.Render()

...

<script type="text/javascript" class="source">

function showSelectedCustomer(control, args) {

    $("#selectedCustomer").html(`Selected Customer: <b>${args.selectedValues[0]} (${args.selectedOptions[0].text})</b>`)

}

</script>

...

 

 

 

Copyright © 2023 DbNetLink