Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
330
aspx grid updating
posted

I have a grid which I am attempting to update using a webmethod in aspx.  I get an error coming back about server not sending a proper response back.  When I debug, the method is not being called.   I think it has to do with the method signature.  The grid loads up just fine and the paging works as well.  I have simplified the grid but subbing in a json object for the data source.

var subs = [

{ IDX: 1, BarraModelId: "USE3L", BarraId: "KORACL3", AltBarraId: "USA9EX1" }

];

$("#SecuritySubs").igGrid({

columns: [

{ key: "IDX", dataType: "number", width: "10px" },

{ headerText: "Barra Model ID", key: "BarraModelId", dataType: "string", width: "150px"},

{ headerText: "Barra Id", key: "BarraId", dataType: "string", width: "150px" },

{ headerText: "Alternate Barra Id", key: "AltBarraId", dataType: "string", width: "150px" }

],

autoCommit: true,

defaultColumnWidth: 100,

alternateRowStyles: false,

primaryKey: "IDX",

requestType: "POST",

responseDataKey: "d.Items",

caption: "Barra Security Substitution",

// dataSourceUrl: "Main.aspx/GetSubstitutions",

dataSource: subs,

updateUrl: "Main.aspx/Update",

autoGenerateColumns: false,

features: [

{

name: "Filtering",

type: "local",

mode: "advanced",

filterDialogWidth: 600,

filterDialogHeight: 350,

filterDialogColumnDropDownDefaultWidth: 175,

filterDialogFilterDropDownDefaultWidth: 125,

filterDialogContainment: "window"

},

{

name: "Sorting",

type: "local",

columnSettings: [

{

columnIndex: 0,

allowSorting: false

}]

},

{

name: "Paging",

type: "remote",

pageSize: 50,

recordCountKey: "d.TotalRecordsCount",

pageSizeUrlKey: "pageSize",

pageIndexUrlKey: "pageIndex",

currentPageIndex: 0,

persist: false,

pageIndexChanging: function (event, args) {

},

pageIndexChanged: function (event, args) {

}

},

{

name: "Selection",

mode: "row"

},

{

name: "Updating",

enableAddRow: true,

editMode: "row",

editRowEnded: function (evt, ui) {

if (ui.update || ui.rowAdding) {

// alert('saving');

$("#SecuritySubs").igGrid("saveChanges");

}

},

saveChangesErrorHandler: function (jqXHR, textStatus, errorThrown) {

// debugger

$("#message").text("An error occurred while saving the changes. Error details: " + errorThrown);//.fadeIn(3000).fadeOut(5000);

},

enableDeleteRow: true,

rowEditDialogContainment: "owner",

showReadonlyEditors: false,

enableDataDirtyException: false,

showDoneCancelButtons: true,

columnSettings: [

{

columnKey: "IDX",

readOnly: true

},

{

columnKey: "BarraModelId",

editorType: "text"

},

{

columnKey: "BarraId",

editorType: "text",

},

{

columnKey: "AltBarraId",

editorType: "text",

validation: true,

required: true,

}]

}

],

width: "900px",

height: '400px'

//dataSource: subs,

});

 

I set the grid to use the updateUrl: "Main.aspx/Update".  The method signature on the back end is the following.

[System.Web.Services.WebMethod(EnableSession = true)]

public static bool Update()

{

return true;

}

The method does not get called.  I am calling the saveChanges function but no server method gets called.   How do I use updating within aspx.

Thanks,

John

Parents Reply
  • 200
    Offline posted in reply to CodeGrunt

    Hello John,

    I am sorry for the delay.

    Regarding the question about updating the hidden columns you can handle the editRowEnding event. Since the updating isn’t finished you can change the values field of the ui param which would result in change the column value.

    For example if you have a column with key “HiddenColumn” and want to set the value after adding new row to “default value”:

    editRowEnding: function (evt, ui) {

       if(ui.rowAdding) {

           ui.values["HiddenColumn"] = "default value";

       }

    },

    I have attached a sample showing this solution. You can try to first add row and then show the “HiddenColumn” to show its value.

    Regarding the initial matter about SaveChanges:

    I still can’t quite figure out why the update method is not called. The grid does make the call but the server side doesn’t seem to handle it. I will continue to investigate the issue.

    In the meantime you can try to use manually ajax requests to the server.

    I will get back to you with an update of the progress by the end of 03/01/2018.

    Kind Regards

    UpdateHiddenCellsSample.zip

Children