Sg1team
Sg1team

Reputation: 155

Access row data via client side API of GridView

I have a DevExpress GridView in my Asp.NET MVC 4 application and want to access row data on the client side via JavaScript. At the moment I am doing the following:

Specify which values should be transmitted to js function ChangeDetailsTab:

function OnGridFocusedRowChanged(s, e) {
        s.GetRowValues(s.GetFocusedRowIndex(),
            'MOL_REGID;BATCH_NAME;MOL_NAME;MOL_ENTERED_BY;', ChangeDetailsTab);
}

Access values from array received by ChangeDetailsTab:

function ChangeDetailsTab(rowData) {

    var molRegId= rowData[0];
    var batchName= rowData[1];
    var molName= rowData[2];
    var molEnteredBy= rowData[3];
}

This approach makes it quite bad to access a large number of values or add/remove values later because the column names have to be specified in one large string (see example 1 line 3).

Has anyone a better solution for this problem?

Upvotes: 1

Views: 5875

Answers (3)

Jamaurice Holt
Jamaurice Holt

Reputation: 106

Which method is faster? I'm loading multiple values but it seems slow for some reason.

I'm doing the setup similar to what you have but I have about 25 - 30 values being loaded.

function insuranceselectionchange() {
   insuranceselection.GetRowValues(insuranceselection.GetFocusedRowIndex(), 'CarrierName;CarrierAddress;CarrierAddress2')
}

function SetInsuranceValues(values) {
   CarrierName.SetText(values[0]);
   CarrierAddress.SetText(values[1]);
   CarrierAddress2.SetText(values[2]);
}

Upvotes: 0

Chakavak Behzad
Chakavak Behzad

Reputation: 807

this is best way,Of course a any way for this,you can called in C# Code,in CustomCallback you can run it,in client side on the javascript you can perform,such
ASPxGridView1.PerformCallback()(ASPxGridView1 has a event that named CustomCallback)with this you without reload page can get value of C# code in C# Code :

ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex,"column1","column2",....)

of course you remember that should called this event from java script in client-side

Upvotes: 2

Mikhail
Mikhail

Reputation: 9300

The client-side GetRowValues is specially designed for this purpose.

I believe it is the best solution.

Upvotes: 2

Related Questions