We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Client side events?

I'm looking to trigger some client side code (JavaScript) post row selection in the grid. I've added my own routine to the "ClientSideRecordSelectionEvent" method. When a row in the grid is clicked the client side JavaScript is fired. In the documentation there is this blurb:

"ClientSideRecordSelectionEvent

Triggered for every row in the grid when it is clicked.
getRow()//contains the row object (DOM)
getRecord()//contains the record object (JSON)
row //contains the row object (DOM)
record //returns the record object (JSON) "

I've tried adding "row" and "record" to my JavaScript function arguments but they don't seem to contain anything.

//Handle Grid row click event.
function OnTimeCardClick(row, record) {
try {
if (row != null) {
alert("Row = " + row);
}

if (record != null) {
alert("Record = " + record);
}
} catch (ex) {
alert("OnTimeCardClick - " + ex.Message);
}
}





5 Replies

MK Maithiliy K Syncfusion Team November 12, 2010 01:30 PM UTC

Hi Greg,

Thanks for your patience.

I've reviewed your code. I found that the arguments which you have been passed are wrong. So we suggest you to pass the “sender” and “args” as the arguments for OnTimeCardClick() function.

Please refer the updated code snippet for OnTimeCard

//Handle Grid row click event.
function OnTimeCardClick(sender, args) {
try {
if (args.row != null) {
alert("Row = " + args.row);
}

if (args.record != null) {
alert("Record = " + args.record);
}
} catch (ex) {
alert("OnTimeCardClick - " + ex.Message);
}
}

Let us know if you have any queries.

Regards
K.Maithiliy




GC Greg Clouston November 17, 2010 03:27 PM UTC

That worked thanks!

Now for the next step. How do I get the value of the cells in the row? What I am looking to do is get an index value from the row and pass it back the controller. The controller will query the database for additional information and return it to the view. I think I've got the Ajax request and controller part figured out from the drag and drop example.



KD Krishnaraj D Syncfusion Team November 18, 2010 11:16 AM UTC

Hi Greg Clouston,

You can get the values of the selected row using the below code snippets. Also you can get the selected row index using "args.row.rowIndex" property.


//Handle Grid row click event.
function OnTimeCardClick(sender, args) {
try {
//To get the selected row index
if (args.row != null) {
alert("RowIndex = " + args.row.rowIndex);
}
//To get the values of the selected row
if (args.record != null) {
$.each(args.record, function(index, value) {
alert(index + ': ' + value);
});

}
} catch (ex) {
alert("OnTimeCardClick - " + ex.Message);
}
}

Please let us know if you have any queries.

Regards,
Krishnaraj D



GC Greg Clouston November 19, 2010 08:22 PM UTC

That worked. Thanks again.



KD Krishnaraj D Syncfusion Team November 22, 2010 05:28 AM UTC

Hi Greg Clouston,

Good to hear that you have everything working. Please let us know if you have any further queries.

Regards,
Krishnaraj D


Loader.
Live Chat Icon For mobile
Up arrow icon