Overall, I'm 85% satisified with how DevExpress implemented this control. The 15% of dissatisfaction that remains is distributed across missing features, method semantics, and the lack of documentation for the Client-Side API. Since my first two complaints are based on my opinion and I have no influence on how DevExpress conducts its business - I will use this post to cover the absolute basics for exercising the JavaScript API provided by the ASPxGridView control.
Accessing the Client-Side events is done by clicking on the smart dag on a ASPxGridView control while in design mode. With the "Tasks" panel open:
- Click the link for "Client-Side Events..."
- Select the event that you wish to customize.
- You'll see an empty function:
- The two parameters passed into the function are the sender object (that's the 's' parameter which is the ASPxGridView in our example) and the event object.
- For this tutorial let's detect a selection change within the ASPxGridView and perform a simple validation on selection to enable or disable a button that's on the same form. After selecting the SelectionChanged event I provide the following JavaScript:
function(s, e) {
s.GetSelectedFieldValues("ID",
function onGetValues(result){
var button = document.getElementById("btnCreateID");
if (s.GetSelectedRowCount() != 1) {
button.disabled = true;
} else {
if (result[0] = null)
button.disabled = false;
else
button.disabled = true;
}});
}
The above code invokes the GetSelectedFieldValues method from the Client-Side API and supplies the column value we wish to retrieve (a column named "ID" in this case) and a callback function that's used to process the result of getting the selected field values. In our example if we've selected one column and if that column doesn't already have an ID assigned to it, the create ID button is enabled.
function(s, e) {
}
No comments:
Post a Comment