Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 551405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:23:25+00:00 2026-05-13T11:23:25+00:00

And the script used is <script type=text/javascript> var lastSelection; var idCategoria; var nomeCategoria; function

  • 0

And the script used is

<script type="text/javascript">

        var lastSelection;
        var idCategoria;
        var nomeCategoria;

        function editRow(id) {
            if (id && id !== lastSelection) {
                var grid = jQuery("#<%= JQGrid1.ClientID %>");

                if (document.getElementById(lastSelection + "_NomeCategoria") != null) {
                    if ( document.getElementById(lastSelection + "_NomeCategoria").value != undefined ) {
                        var objeto = document.getElementById(lastSelection + "_NomeCategoria");
                        idCategoria = objeto.value;
                        nomeCategoria = objeto[objeto.selectedIndex].text;
                    }
                }

                if (lastSelection != undefined) {
                    grid.updateGridRows("{IdCategoria:" + idCategoria + "}", lastSelection);
                    grid.saveRow(lastSelection, false);
                    //grid.setCell(lastSelection, "IdCategoria", idCategoria);
                    //grid.setRowData(lastSelection, "{IdCategoria:" + idCategoria + "}");
                }

                try
                {
                    grid.restoreRow(lastSelection, defineCategoria);
                }
                catch(err)
                {
                    alert(err.description);
                }
                grid.editRow(id, true, selecionaCategoria);
                lastSelection = id;
            }
        }

        function selecionaCategoria(id) {

            var grid = jQuery("#<%= JQGrid1.ClientID %>");
            var linha = grid.getRowData(id);
            var idCategoria = linha.IdCategoria;
            var comboCategorias = document.getElementById(id + "_NomeCategoria");
            if (idCategoria != "" && idCategoria != undefined) {
                try {
                    for (var i = 0; i < comboCategorias.childNodes.length; i++) {
                        if (comboCategorias.childNodes[i].value == idCategoria) {
                            comboCategorias.childNodes[i].selected = true;
                            break;
                        }
                    }
                }
                catch (err) {
                    alert(err.description);
                }
            }
        }

        function defineCategoria(id) {
            var grid = jQuery("#<%= JQGrid1.ClientID %>");
            grid.setCell(id, "NomeCategoria", DefineUrlCategoria(idCategoria, nomeCategoria));
        }

        // The FormatFunction for CustomFormatter gets three parameters
        // cellValue - the original value of the cell
        // options - as set of options, e.g
        //   options.rowId - the primary key of the row
        //   options.colModel - colModel of the column
        // rowData - array of cell data for the row, so you can access other cells in the row if needed

        function DefineUrl(cellValue, options, rowObject) {
            var caminho = "";
            if (isArray(rowObject)) {
                if (rowObject[1] != "" && rowObject[1] != undefined) {
                    //var caminho = "<a href='/Ferramenta/Graficos/GraficoCategoria.aspx?idCategoria=" + rowObject[1] + "'>" + cellValue + "</a>";
                    caminho = DefineUrlCategoria(rowObject[1], cellValue);
                }
                else {
                    caminho = cellValue;
                }
            }
            else {
                if (idCategoria != "0") {
                    caminho = DefineUrlCategoria(idCategoria, nomeCategoria);
                }
                else {
                    caminho = nomeCategoria;
                }
            }
            return caminho;
        }

        function isArray(o) {
            return (typeof (o.length) == "undefined") ? false : true;
        }


        function DefineUrlCategoria(idCategoria, nomeCategoria) {
            var caminho = "<a href='/Ferramenta/Graficos/GraficoCategoria.aspx?idCategoria=" + idCategoria + "'>" + nomeCategoria + "</a>";

            return caminho;
        }
    </script>

When the rows are not in edit mode the fifth columns shows a link and while editing it shows a dropdown. To select the correct item in the dropdown I use the second column that has the ID that came from the database.

The problem is that after changing the item and saving it to the database, this column value doesn’t change. How can I do it after the grid.saveRow(lastSelection, false); ?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:23:25+00:00Added an answer on May 13, 2026 at 11:23 am

    I have found the solution !

    I changed the code below

    if (lastSelection != undefined) {
        grid.updateGridRows("{IdCategoria:" + idCategoria + "}", lastSelection);
        grid.saveRow(lastSelection, false);
        //grid.setCell(lastSelection, "IdCategoria", idCategoria);
        //grid.setRowData(lastSelection, "{IdCategoria:" + idCategoria + "}");
    

    }

    To this

    if (lastSelection != undefined) {
        grid.setRowData(lastSelection, {IdCategoria:idCategoria});
        grid.saveRow(lastSelection, false);}
    

    The problem was that I was passing the second parameter as a string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<script type=text/javascript> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxxx-x']); _gaq.push(['_setCustomVar(1,'landline','acct_Summary']); _gaq.push(['_trackEvent','Telemedia','bill_guide']); (function() {
Possible Duplicate: HTML Text Input allow only Numeric input I used this script function
I used to use this script for jquery email obfuscation: $(.replaceAt).replaceWith(@); $(.obfuscate).each(function () {
I was using the below code provided by Google for Google Analytics. <script type=text/javascript>
I am making a jQuery ajax post in a javascript function used by a
Hi I want to replace document.write(unescape(%3Cscript src=' + gaJsHost + google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E)); with (function()
The following script is used to save a file to the desktop: var ba:ByteArray
i used this script to animate some divs with jquery and css. now i
I used this script to create a jQuery accordion. Check out the working jsFiddle
in jquery 1.3.2 for jsonp requests i used to this var _options = {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.