jQuery UI Widgets Forums Plugins Data Adapter loaderror function

This topic contains 1 reply, has 2 voices, and was last updated by  Nadezhda 9 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • loaderror function #70839

    Keshavan
    Participant

    Hi,

    How to redirect to a new URL in loaderror function ?, (I want to do URL redirection in loaderror function, as my Redirect on server side is not called as CALLBACK (loaderror) executes once the server call fails).

    I have pasted my code below.

    Thanks,

    Keshavan

    <!DOCTYPE html>
    @functions{
        public string TokenHeaderValue()
        {
            string cookieToken, formToken;
            AntiForgery.GetTokens(null, out cookieToken, out formToken);
            return cookieToken + ":" + formToken;
        }
    }
    <html lang="en">
    <head>
        <title id='Description'>
            In order to enter in edit mode, click any of the 'Edit' buttons. To save the changes, click the 'Save' button in the popup dialog.
            To cancel the changes click the 'Cancel' button in the popup dialog.
        </title>
        <link rel="stylesheet" href="/Content/Site.css" type="text/css" />
        <link rel="stylesheet" href="/jqWidgets/jqwidgets/styles/jqx.base.css" type="text/css" />
        <link rel="stylesheet" href="/jqWidgets/jqwidgets/styles/jqx.ui-sunny.css" type="text/css" />
        <script type="text/javascript" src="/JqWidgets/scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyACml1UshMGEbt1hZLg7rJ08X4qsbhqsMM&sensor=false"></script>
        <script type="text/javascript" src="/Scripts/google-map.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxdata.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxvalidator.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxcheckbox.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxinput.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxnumberinput.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxdatetimeinput.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxbuttongroup.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxradiobutton.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.edit.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.pager.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.sort.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.filter.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.grouping.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.aggregates.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.columnsresize.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxgrid.columnsreorder.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxwindow.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxpanel.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/globalization/globalize.js"></script>
        <script type="text/javascript" src="/JqWidgets/jqwidgets/jqxcalendar.js"></script>
        <style>
            input[type=text]:focus {
                border-color: #0000ff;
                border-width: 3px;
                background-color: aliceblue;
            }
        </style>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#addrowbutton").jqxButton({ width: '2.5%', height: '27', theme: 'ui-sunny' });
                $("#deleterowbutton").jqxButton({ width: '2.5%', height: '27', theme: 'ui-sunny' });
                $("#resizebutton").jqxButton({ width: '4.5%', height: '27', theme: 'ui-sunny' });
                $("#addressbutton").jqxButton({ width: '100%', height: '27', theme: 'ui-sunny' });
                $("#Cancel").jqxButton({ theme: 'ui-sunny', width: '32%' });
                $("#Save").jqxButton({ theme: 'ui-sunny', width: '32%' });
                var generaterow = function (id) {
                    var row = {};
                    row["CompId"] = id;
                    row["CompanyName"];
                    //   row["BusinessUnit"] = 0;
                    row["FiscalStartDate"];
                    row["FirstMonth"];
                    row["NoOfPeriods"];
                    row["AddressLine1"];
                    row["AddressLine2"];
                    row["City"] = "Chennai";
                    row["State"] = "TamilNadu";
                    row["ZipCode"];
                    row["CompanyEmail"];
                    row["PanNo"];
                    row["TanNo"];
                    row["RegNo"];
                    row["AuthorizedSignatory"];
                    row["AdminPhone"];
                    row["AdminMobile"];
                    row["AdminEmail"];
                    row["Lattitude"] = 0;
                    row["Longitude"] = 0;
                    return row;
                }
                var source =
                {
                    datatype: "json",
                    datafields:
                    [
                        { name: 'CompId' },
                        { name: 'CompanyName', type: 'string' },
                    //    { name: 'BusinessUnit', type: 'string' },
                        { name: 'FiscalStartDate', type: 'date', format: 'MM/dd/yyyy' },
                        { name: 'FirstMonth', type: 'number' },
                        { name: 'NoOfPeriods', type: 'number' },
                        { name: 'AddressLine1', type: 'string' },
                        { name: 'AddressLine2', type: 'string' },
                        { name: 'City', type: 'string' },
                        { name: 'State', type: 'string' },
                        { name: 'ZipCode', type: 'string' },
                        { name: 'PanNo', type: 'string' },
                        { name: 'TanNo', type: 'string' },
                        { name: 'RegNo', type: 'string' },
                        { name: 'CompanyEmail', type: 'string' },
                        { name: 'AuthorizedSignatory', type: 'string' },
                        { name: 'AdminPhone', type: 'string' },
                        { name: 'AdminMobile', type: 'string' },
                        { name: 'AdminEmail', type: 'string' },
                        { name: 'Lattitude' },
                        { name: 'Longitude' },
                    ],
                    id: 'CompId',
                    url: '/Compani/GetCompanies',
                    async: false,
                    addrow: function (rowid, rowdata, position, commit) {
                        // synchronize with the server - send insert command
                        $.ajax
                            ({
                                cache: false,
                                dataType: 'json',
                                url: '/Compani/Add',
                                data: rowdata,
                                type: "POST",
                                headers: {
                                    'RequestVerificationToken': '@TokenHeaderValue()'
                                },
                                success: function (data, status, xhr) {
                                    // insert command is executed.
                                    commit(true);
                                    //      $('#n1').val(data.GroupCompanyId);
                                    //        alert("n1 value is " + n1);
                                },
                                error: function (jqXHR, textStatus, errorThrown) {
                                    alert("err Occured  " + errorThrown);
                                    commit(false);
                                }
                            });
                    },
                    updaterow: function (rowid, rowdata, commit) {
                        // synchronize with the server - send update command
    
                        {
                            var dref = new Date();
                            rowdata.FiscalStartDate = ((dref.getMonth() + 1) + "/" + dref.getDate() + "/" + dref.getFullYear());
                        }
                        {
                            $.ajax(
                                     {
                                         cache: false,
                                         dataType: 'json',
                                         url: '/Compani/Update',
                                         data: rowdata,
                                         type: "POST",
                                         headers: {
                                             'RequestVerificationToken': '@TokenHeaderValue()'
                                         },
                                         success: function (data, status, xhr) {
                                             alert("Update success !!");
                                             commit(true);
                                         },
                                         error: function (jqXHR, textStatus, errorThrown) {
                                             alert("Update Fails ... " + errorThrown);
                                             commit(false);
                                         }
                                     }
                                 );
                        }
                    }
                };
                var dataAdapter = new $.jqx.dataAdapter(source, {
                    downloadComplete: function (data, status, xhr) {
                        console.log('complete:' + status);
                    },
                    loadComplete: function (data) {
                        var length = dataAdapter.records.length;
                        console.log('loadcomplete' + data + "Record count : " + length);
                    },
                    loadError: function (xhr, status, error) {
                        alert("error Occured while fetching server data -  , " + status +  ", " + error);
                        console.log("error Occured while fetching server data -  , " + status +  ", " + error);
                    }
                });
                var result = false;
                $("#popupWindow").jqxWindow({
                    width: '40%', height: '100%', resizable: true, theme: 'ui-sunny', isModal: false, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.01, title: "Company Edit",
                });
                // initialize jqxGrid
                $("#jqxgrid").jqxGrid(
                {
                    width: '100%',  // 960
                    height: 150,
                    source: dataAdapter,
                    theme: 'ui-sunny',
                    columnsresize: true,
                    columnsreorder: true,
                    enabletooltips: true,
                    pageable: true,
                    editable: true,
                    sortable: true,
                    selectionmode: 'singlerow',
                    filterable: true,
                    columnsresize: true,
                    columnsreorder: true,
                    enabletooltips: true,
                    //    groupable: true,
                    autoshowfiltericon: false,
                    showfiltercolumnbackground: true,
                    showsortcolumnbackground: true,
                    toolbarheight: 20,
                    altrows: true,
                    columns:
                    [
                        { text: 'Company', datafield: 'CompanyName', pinned: true, width: "35%" },
                        {
                            text: 'Select', width: 50, datafield: 'select', columntype: 'button', pinned: true, cellsrenderer: function () {
                                return "select";
                            }, buttonclick: function (row) {
                                // open the popup window when the user clicks a button.
                                $('#addressForm').jqxValidator('hideHint', '#address');
                                editrow = row;
                                var offset = $("#jqxgrid").offset();
                                $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.left) + 90, y: parseInt(offset.top) + (-80) } });
                                // get the clicked row's data and initialize the input fields.
                                var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
                                $("#compId").val(dataRecord.CompId);
                                $("#companyName").val(dataRecord.CompanyName);
                          //    $("#fiscalStartDate").jqxDateTimeInput('val');
                                $("#fiscalStartDate").val(dataRecord.FiscalStartDate);
                                $("#firstMonth").val(dataRecord.FirstMonth);
                                $("#noOfPeriods").val(dataRecord.NoOfPeriods);
                                $("#addressLine1").val(dataRecord.AddressLine1);
                                $("#address").val(dataRecord.AddressLine1);
                                $("#addressLine2").val(dataRecord.AddressLine2);
                                $("#city").val(dataRecord.City);
                                $("#state").val(dataRecord.State);
                                $("#zipCode").val(dataRecord.ZipCode);
                                $("#companyEmail").val(dataRecord.CompanyEmail);
                                $("#panNo").val(dataRecord.PanNo);
                                $("#tanNo").val(dataRecord.TanNo);
                                $("#regNo").val(dataRecord.RegNo);
                                $("#authorizedSignatory").val(dataRecord.AuthorizedSignatory);
                                $("#adminPhone").val(dataRecord.AdminPhone);
                                $("#adminMobile").val(dataRecord.AdminMobile);
                                $("#adminEmail").val(dataRecord.AdminEmail);
                                $("#lattitude").val(dataRecord.Lattitude);
                                $("#longitude").val(dataRecord.Longitude);
                                // show the popup window.
                                $("#popupWindow").jqxWindow('open');
                                refrecord = dataRecord;
                            }
                        },
      
                        {
                            text: 'FiscalStart', datafield: 'FiscalStartDate', width: '10%', columntype: 'datetimeinput', width: 90, align: 'center', cellsalign: 'right', cellsformat: "dd/MM/yyyy",editable: true,
                            createeditor: function (row, cellvalue, editor) {
                                editor.jqxDateTimeInput({ culture: 'fr-FR' });
                            }
                        },
                      { text: 'First Month', datafield: 'FirstMonth', width: "10%" },
                      { text: 'No Of Periods', datafield: 'NoOfPeriods', width: "10%" },
                      { text: 'Address', datafield: 'AddressLine1', width: "25%" },
                      { text: ' ', datafield: 'AddressLine2', width: "25%" },
                      { text: 'City', datafield: 'City', width: "15%" },
                      { text: 'State', datafield: 'State', width: "15%" },
                      { text: 'ZipCode', datafield: 'ZipCode', width: "15%" },
                      { text: 'Land Phone', datafield: 'AdminPhone', width: "15%" },
                      { text: 'Email', datafield: 'CompanyEmail', width: "30%" },
                      { text: 'Pan No', datafield: 'PanNo', width: "20%" },
                      { text: 'Tan No', datafield: 'TanNo', width: "20%" },
                      { text: 'Registration No', datafield: 'RegNo', width: "20%" },
                      { text: 'Manager Name', datafield: 'AuthorizedSignatory', width: "20%" },
                      { text: 'Manager Mobile', datafield: 'AdminMobile', width: "15%" },
                      { text: 'Manager Email', datafield: 'AdminEmail', width: "15%" }
                    ]
                });
                $("#jqxgrid").jqxGrid('selectrow', 0);
                //resize
                $("#resizebutton").click(function () {
                    $("#jqxgrid").jqxGrid('autoresizecolumns');
                });
                // initialize the popup window and buttons.
                $("#popupWindow").on('open', function () {
                    $("#compId").jqxInput('selectAll');
                });
                var map, geocoder, marker, infoWindow;
                try {
                    latlng = new google.maps.LatLng(13.0604220, 80.2495830);
                } catch (e) {
                    alert("Can't render map : " + e.message)
                }
                var options =
                    {
                        zoom: 15,
                        center: latlng,
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        navigationControl: true,
                        navigationControlOptions: {
                            style: google.maps.NavigationControlStyle.ZOOM_PAN
                        },
                        streetViewControl: true
                    };
                map = new google.maps.Map(document.getElementById('map'), options);
                $('#map').width("100%").height(1000);
                $("#addressbutton").click(function () {
                    var geocoder, marker, infowindow;
                    result = $('#addressForm').jqxValidator('validate');
                    if (result == true) {
                        adrs = $("#address").val();
                        if (!geocoder) {
                            geocoder = new google.maps.Geocoder();
                        }
                        var geocoderRequest =
                        {
                            address: adrs
                        }
                        $("#addressLine1").val(adrs);
                        geocoder.geocode(geocoderRequest, function (results, status) {
                            // Check if status is OK before proceeding
                            if (status == google.maps.GeocoderStatus.OK) {
                                // Center the map on the returned location
                                map.setCenter(results[0].geometry.location);
                                // Check to see if we've already got a Marker object
                                if (!marker) {
                                    // Creating a new marker and adding it to the map
                                    marker = new google.maps.Marker
                                    ({
                                        map: map,
                                        title: 'Click me',
                                        icon: 'http://gmaps-samples.googlecode.com/svn/trunk/markers/green/marker1.png'
                                    });
                                }
                            }
                            // Setting the position of the marker to the returned location
                            marker.setPosition(results[0].geometry.location);
                            $("#lattitude").val(results[0].geometry.location.lat());
                            $("#longitude").val(results[0].geometry.location.lng());
                            if (!infoWindow) {
                                infoWindow = new google.maps.InfoWindow();
                            }
                            google.maps.event.addListener(marker, 'click', function () {
                                var content = '<div id="info">' +
                                 $("#companyName").val() +
                                '<br/>' + "Latitude  : " + results[0].geometry.location.lat() +
                                '<br/>' + "Longitude : " + results[0].geometry.location.lng() +
                                '</div>';
                                map.setCenter(marker.getPosition());
                                map.setZoom(17);
                                infoWindow.setContent(content);
                                infoWindow.open(map, marker);
                                $("#lattitude").val(results[0].geometry.location.lat());
                                $("#longitude").val(results[0].geometry.location.lng());
                            });
                        });
                    }
                });
                $('#addressForm').jqxValidator
                  ({
                      rules: [
                               { input: '#address', message: 'Location name is required!', action: 'keyup, blur', rule: 'required' },
                               { input: '#address', message: 'Location name must be between 3 and 50 characters!', action: 'keyup, focus', rule: 'length=3,50' },
    
                      ]
                  });
                $("#compId").jqxInput({ theme: "ui-sunny" });
                $("#companyName").jqxInput({ theme: "ui-sunny" });
                $("#fiscalStartDate").jqxDateTimeInput({ width: '180px', height: " 20px", formatString: 'MM/dd/yyyy', theme: 'ui-sunny' });
                $("#firstMonth").jqxInput({ theme: "ui-sunny" });
                $("#noOfPeriods").jqxInput({ theme: "ui-sunny" });
                $("#addressLine1").jqxInput({ theme: "ui-sunny" });
                $("#addressLine2").jqxInput({ theme: "ui-sunny" });
                $("#city").jqxInput({ theme: "ui-sunny" });
                $("#state").jqxInput({ theme: "ui-sunny" });
                $("#zipCode").jqxInput({ theme: "ui-sunny" });
                $("#panNo").jqxInput({ theme: "ui-sunny" });
                $("#tanNo").jqxInput({ theme: "ui-sunny" });
                $("#regNo").jqxInput({ theme: "ui-sunny" });
                $("#companyEmail").jqxInput({ theme: "ui-sunny" });
                $("#authorizedSignatory").jqxInput({ theme: "ui-sunny" });
                $("#adminPhone").jqxInput({ theme: "ui-sunny" });
                $("#adminMobile").jqxInput({ theme: "ui-sunny" });
                $("#adminEmail").jqxInput({ theme: "ui-sunny" });
                $("#lattitude").jqxInput({ theme: "ui-sunny" });
                $("#longitude").jqxInput({ theme: "ui-sunny" });
                $("#address").jqxInput({ theme: "ui-sunny" });
                $("#compId").width("10%");
                $("#compId").height("3%");
                $("#companyName").width("200%");
                $("#companyName").height("3%");
             //   $("#fiscalStartDate").width("200%");
             //   $("#fiscalStartDate").height("3%");
                $("#firstMonth").width("200%");
                $("#firstMonth").height("3%");
                $("#noOfPeriods").width("200%");
                $("#noOfPeriods").height("3%");
                $("#addressLine1").width("200%");
                $("#addressLine1").height("200%");
                $("#addressLine2").width("200%");
                $("#addressLine2").height("3%");
                $("#city").width("100%");
                $("#city").height("3%");
                $("#state").width("200%");
                $("#state").height("3%");
                $("#zipCode").width("100%");
                $("#zipCode").height("3%");
                $("#adminPhone").width("100%");
                $("#adminPhone").height("3%");
                $("#companyEmail").width(200);
                $("#companyEmail").height(20);
                $("#authorizedSignatory").width("100%");
                $("#authorizedSignatory").height("3%");
                $("#adminPhone").width("100%");
                $("#adminPhone").height("3%");
                $("#adminMobile").width("100%");
                $("#adminMobile").height("3%");
                $("#adminEmail").width(200);
                $("#adminEmail").height(20);
                $("#panNo").width("100%");
                $("#panNo").height("3%");
                $("#tanNo").width("100%");
                $("#tanNo").height("3%");
                $("#regNo").width("100%");
                $("#regNo").height(20);
                $("#lattitude").width("100%");
                $("#lattitude").height("3%");
                $("#longitude").width("100%");
                $("#longitude").height("3%");
                $("#Cancel").click(function () {
                    $('#testForm').jqxValidator('hideHint', '#companyName');
                });
                var editrow = -1;
                // create new row.
                $("#addrowbutton").bind('click', function () {
                    var datainformation = $("#jqxgrid").jqxGrid('getdatainformation');
                    var rowscount = datainformation.rowscount;
                    if (rowscount == null || rowscount == undefined)
                        var rowscount = 0;
                    editrow = rowscount + 1;
                    var datarow = generaterow(rowscount + 1);
                    {
                        var dref = new Date();
                        datarow.FiscalStartDate = ((dref.getMonth() + 1) + "/" + dref.getDate() + "/" + dref.getFullYear());
                    }
                    if (rowscount <= 1)
                        $("#jqxgrid").jqxGrid('addrow', (rowscount + 1), datarow, 'top');
                    else
                        alert("No more Inserts !!");
                });
                // initialize the input fields.
                var data = {};
                var adrs;
                var refrecord;
                $("#jqxWidget1").jqxPanel({ width: "100%", height: 230, theme: 'ui-sunny' });
                $('#jqxWidget1').jqxPanel({ autoUpdate: true });
                // Validate row
                $('#testForm').jqxValidator
                ({
                    rules:
                        [
                                 { input: '#companyName', message: 'CompanyName is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#fiscalStartDate', message: 'Fiscal Start is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#firstMonth', message: 'First Month is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#noOfPeriods', message: 'Number of Periods is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#addressLine1', message: 'Address Line 1 is required!', action: 'keyup, blur', rule: 'required' },
                                 {
                                     input: '#addressLine1', message: 'Address Line 1 mu<a href="~/Controllers/ImportEFController.cs">~/Controllers/ImportEFController.cs</a>st be between 5 and 50 characters!', action: 'keyup, focus', rule: function (input, commit) {
                                         // call commit with false, when you are doing server validation and you want to display a validation error on this field.
                                         if ('length=5,50') {
                                             $("#address").val($("#addressLine1").val());
                                             return true;
                                         }
                                         return false;
                                     }
                                 },
                                 { input: '#city', message: 'City is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#city', message: 'City  must be between 3 and 50 characters!', action: 'keyup, focus', rule: 'length=3,50' },
                                 { input: '#state', message: 'State is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#state', message: 'State  must be between 3 and 50 characters!', action: 'keyup, focus', rule: 'length=3,50' },
                                 { input: '#zipCode', message: 'ZipCode is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#zipCode', message: 'ZipCode  must be 6 characters!', action: 'keyup, focus', rule: 'length=6,10' },
                                 { input: '#companyEmail', message: 'Company Email is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#companyEmail', message: 'Invalid emailID!', action: 'keyup, focus', rule: 'email' },
                                 { input: '#panNo', message: 'PAN number is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#panNo', message: 'PAN number must be 10 characters in length!', action: 'keyup, focus', rule: 'length=10,10' },
                                 { input: '#tanNo', message: 'TAN number is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#tanNo', message: 'TAN number must be between 10 characters in length!', action: 'keyup, focus', rule: 'length=10,10' },
                                 { input: '#regNo', message: 'Registration number is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#regNo', message: 'Registration number must be between 5 and 20 characters!', action: 'keyup, focus', rule: 'length=5,20' },
                                 { input: '#authorizedSignatory', message: 'Manager name is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#authorizedSignatory', message: 'Manager name must be between 10 and 50 characters!', action: 'keyup, focus', rule: 'length=10,50' },
                                 { input: '#adminPhone', message: 'Manager Phone is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#adminPhone', message: 'Manager Phone  must be between 8 and 50 characters!', action: 'keyup, focus', rule: 'length=8,50' },
                                 { input: '#adminMobile', message: 'Manager Mobile is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#adminMobile', message: 'Manager Mobile  must be between 10 and 13 characters!', action: 'keyup, focus', rule: 'length=10,15' },
                                 { input: '#adminEmail', message: 'Manager Email is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#adminEmail', message: 'Manager Email  must be between 5 and 50 characters!', action: 'keyup, focus', rule: 'email' },
                                 { input: '#lattitude', message: 'Lattitude is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#lattitude', message: 'Invalid latitude!', action: 'keyup, focus', rule: 'length=6,20' },
                                 { input: '#longitude', message: 'Longitude is required!', action: 'keyup, blur', rule: 'required' },
                                 { input: '#longitude', message: 'Invalid Longitude!', action: 'keyup, focus', rule: 'length=6,20' }
                        ]
                });
                // update the edited row when the user clicks the 'Save' button.
                $("#Save").click(function () {
                    var result1 = false;
                    result1 = $('#testForm').jqxValidator('validate');
                    if (result1 == true) {
                        row =
                        {
                            CompId: $("#compId").val(), CompanyName: $("#companyName").val(), FiscalStartDate: $("#fiscalStartDate").val(),
                            FirstMonth: $("#firstMonth").val(), NoOfPeriods: $("#noOfPeriods").val(), AddressLine1: $("#addressLine1").val(), AddressLine2: $("#addressLine2").val(),
                            City: $("#city").val(), State: $("#state").val(), ZipCode: $("#zipCode").val(), CompanyEmail: $("#companyEmail").val(),
                            PanNo: $("#panNo").val(), TanNo: $("#tanNo").val(), RegNo: $("#regNo").val(),
                            AuthorizedSignatory: $("#authorizedSignatory").val(), AdminPhone: $("#adminPhone").val(), AdminMobile: $("#adminMobile").val(),
                            AdminEmail: $("#adminEmail").val(), Lattitude: $("#lattitude").val(), Longitude: $("#longitude").val()
                        };
                        var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
                        $('#jqxgrid').jqxGrid('updaterow', rowID, row);
                        $("#popupWindow").jqxWindow('hide');
                    }
                });
            });
            var menuNo = 1;
            var lenth = 14;
    
            for (var j = 1; j <= lenth; j++) {
                if (j == menuNo) {
                    $(("#") + (j)).css("background-color", "maroon");
                }
                else
                    $(("#") + (j)).css("background-color", "null");
            }
        </script>
    </head>
    <body class='default'>
        <div style='margin-left: 1%; width: 200%'>
            <input id="addrowbutton" type="button" style="margin-left: 1%;" value="+" title="Click to add row" />
            <input id="deleterowbutton" type="button" value="-" title="Click to remove row" />
            <input id="resizebutton" type="button" value="Resize" title="Click to resize grid columns" />
        </div>
        <div id='jqxWidget' style="margin-left: 0px; margin-top: 10px;">
            <div id="jqxgrid" style="margin-left: 0px; margin-top: 1px; width: 100%;"></div>
            <div style='width: 100%; height: 300px; margin-top: 1px'>
                <form id="addressForm">
                    <div>
                        <table>
                            <tr>
                                <td> Location Name:</td>
                                <td style="text-align:left">
                                    <input type="text" id="address" class="text-input" />
                                </td>
                                <td>
                                    <input id="addressbutton" type="button" style="margin-top: 1px;" value="Show location" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </form>
                <div id='jqxWidget1' style='width: 100%; height: 300px; margin-top: 1px'>
                    <div id="map"></div>
                </div>
            </div>
            <div id="info">
            </div>
    
            <div id="popupWindow">
                <div>
                    <form id="testForm" action="./">
                        <table >
                            <tr>
                                <td style="text-align: right">Id:</td>
                                <td style="text-align: left">
                                    <input id="compId" type="text"/>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Company:</td>
                                <td style="text-align: left">
                                    <input type="text" id="companyName" class="text-input" placeholder="Company name" autofocus required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Address:</td>
                                <td style="text-align: left">
                                    <input type="text" id="addressLine1" class="text-input" placeholder="Company address" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Address:</td>
                                <td style="text-align: left">
                                    <input type="text" id="addressLine2" class="text-input" placeholder="Use this to complete address" />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">City:</td>
                                <td style="text-align: left">
                                    <input type="text" id="city" class="text-input" placeholder="City name" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">State:</td>
                                <td style="text-align: left">
                                    <input type="text" id="state" class="text-input" placeholder="State name" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Zipcode:</td>
                                <td style="text-align: left">
                                    <input type="text" id="zipCode" class="text-input" placeholder="Zipcode" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Land Phone:</td>
                                <td style="text-align: left">
                                    <input type="text" id="adminPhone" class="text-input" placeholder="Land Phone Number" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Email:</td>
                                <td>
                                    <input type="text" id="companyEmail" class="text-input" placeholder="Company emailId" required />
                                </td>
                            </tr>
                            <tr>
                            <td style="text-align: right">Fiscal Start:</td>
                                <td style="text-align: left">
                                    <div id="fiscalStartDate" placeholder="Fiscal start date" autofocus required > </div>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">First Month:</td>
                                <td style="text-align: left">
                                    <input type="text" id="firstMonth" class="text-input" placeholder="First Month" autofocus required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">No Of Periods:</td>
                                <td style="text-align: left">
                                    <input type="text" id="noOfPeriods" class="text-input" placeholder="No Of Periods" autofocus required />
                                </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: right">Pan No:</td>
                                <td style="text-align: left">
                                    <input type="text" id="panNo" class="text-input" placeholder="PAN number" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">TAN No:</td>
                                <td style="text-align: left">
                                    <input type="text" id="tanNo" class="text-input" placeholder="TAN number" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Registration No:</td>
                                <td style="text-align: left">
                                    <input type="text" id="regNo" class="text-input" placeholder="Registration number" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Manager Name:</td>
                                <td style="text-align: left">
                                    <input type="text" id="authorizedSignatory" placeholder="Authorized signatory name" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Manager Mobile:</td>
                                <td style="text-align: left">
                                    <input type="text" id="adminMobile" class="text-input" placeholder="Manager mobile number" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Manager eMail:</td>
                                <td style="text-align: left">
                                    <input type="text" id="adminEmail" class="text-input" placeholder="Manager emailId" required />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Lattitude:</td>
                                <td style="text-align: left">
                                    <input type="text" id="lattitude" class="text-input" placeholder="No User entry" required readonly="readonly" />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">Longitude:</td>
                                <td style="text-align: left">
                                    <input type="text" id="longitude" class="text-input" placeholder="No User entry" required readonly="readonly" />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right"></td>
                                <td style="padding-top: 10px; text-align: right">
                                    <input style="margin-right: 5px;" type="button" id="Save" value="Save" />
                                    <input id="Cancel" type="button" value="Cancel" />
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </body>
    </html>
    loaderror function #70849

    Nadezhda
    Participant

    Hello Keshavan,

    You may try to set different ‘url’ value in ‘loadError’ callback function. Here is an example:

    var dataAdapter= new $.jqx.dataAdapter(source, {
            loadComplete: function (records) {
               // initialize jqxGrid
            },
    	loadError: function(xhr, status, error)
    	{
    	    source.url = "../sampledata/beverages.txt";
    	}
    }
    dataAdapter.dataBind();

    Best Regards,
    Nadezhda

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.