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.
Unfortunately, activation email could not send to your email. Please try again.

Client side events?

Thread ID:

Created:

Updated:

Platform:

Replies:

97227 Nov 9,2010 09:49 AM Nov 22,2010 12:28 AM ASP.NET MVC (Classic) 5
loading
Tags: Grid
Greg Clouston
Asked On November 9, 2010 09:49 AM

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);
}
}





Maithiliy K [Syncfusion]
Replied On November 12, 2010 08:30 AM

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



Greg Clouston
Replied On November 17, 2010 10:27 AM

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.


Krishnaraj D [Syncfusion]
Replied On November 18, 2010 06:16 AM

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


Greg Clouston
Replied On November 19, 2010 03:22 PM

That worked. Thanks again.


Krishnaraj D [Syncfusion]
Replied On November 22, 2010 12:28 AM

Hi Greg Clouston,

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

Regards,
Krishnaraj D


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;