logo
down
shadow

to add button which will redirect to View Page of current row in JQGrid


to add button which will redirect to View Page of current row in JQGrid

Content Index :

elements) is id, but you use Id instead. The property id: "Id" informs jqGrid about it.
$(function () {
    function viewButton(cellvalue, options, rowObject) {
        return "<button class=\"viewLineItem\" id=\"" +
            options.rowId + "\">View Line   Item</button>";
    }

    $("#grid").jqGrid({
        url: "/Location/LocationsList1",
        datatype: 'json',
        colNames: ['Id', 'Country Name', 'State Name', 'City Name', 'Location Name','View'],
        colModel: [
            { name: 'Id', key: true, hidden: true },
            { name: 'CountryName' },
            { name: 'StateName' },
            { name: 'CityName' },
            { name: 'Name' },
            { name: 'View', editable: false, formatter: viewButton }
        ],
        cmTemplate: { editable: true },
        pager: '#pager',
        rowNum: 10,
        rowList: [10, 20, 30, 40],
        height: '100%',
        viewrecords: true,
        caption: 'Location',
        emptyrecords: 'No records to display',
        jsonReader: { repeatitems: false, id: "Id" }
    });

    $("#jqGridA").click(function (e) {
        var $td = $(e.target).closest("tr.jqgrow>td"),
            rowid = $td.parent().attr("id"),
            p = $(this).jqGrid("getGridParam");

        if ($td.length > 0 && p.colModel[$td[0].cellIndex].name === "View") {
            alert(rowid);
        }
    });
});
$(function () {
    function viewButton(cellvalue, options, rowObject) {
        return "<button class=\"viewLineItem\" id=\"" +
            options.rowId + "\">View Line   Item</button>";
    }

    $("#grid").jqGrid({
        url: "/Location/LocationsList1",
        datatype: 'json',
        colNames: ['Id', 'Country Name', 'State Name', 'City Name', 'Location Name','View'],
        colModel: [
            { name: 'CountryName' },
            { name: 'StateName' },
            { name: 'CityName' },
            { name: 'Name' },
            { name: 'View', editable: false, formatter: viewButton }
        ],
        cmTemplate: { editable: true },
        pager: '#pager',
        rowNum: 10,
        rowList: [10, 20, 30, 40],
        height: '100%',
        viewrecords: true,
        caption: 'Location',
        emptyrecords: 'No records to display',
        jsonReader: { repeatitems: false, id: "Id" },
        beforeSelectRow: function (rowid, e) {
            var $td = $(e.target).closest("tr.jqgrow>td"),
                p = $(this).jqGrid("getGridParam");

            if ($td.length > 0 && p.colModel[$td[0].cellIndex].name === "View") {
                alert(rowid);
            }
        }
    });
});

Comments

to add button which will redirect to View Page of current row in JQGrid
Tag : javascript , By : Johannes
Date : December 05 2020, 12:22 PM

it helps some times The code has some problems
options has no rowid property, but it has rowId property. You should change options.rowid to options.rowId The formatter will be called during building the HTML fragment of the grid body. No element of the grid exist at the moment on the page. Thus you can't use $('#' + rowid).live('click', ...); at the moment. The formatter have to return the HTML fragment, which will be placed in the corresponding cell (inside of
). One misses return button; at the end of the formatter. There are exist well-known name conversion in JavaScript. One should use functions, which starts with capital letter only if you define the constructor of the new class. You see that ViewButton will be displayed in the other color to distinguish classes from other function. You should rename ViewButton to viewButton to hold the standard name conversion of JavaScript. It's better don't specify index property in colModel. In the same way one should not include the properties with the defaul value, like key: false. To specify common property for many columns you can use cmTemplate property. One should reduce the number of global functions, because the functions will be considerd as the properties of window object. instead of usage hidden column with name: 'Id' one can specify id: 'Id' property of jsonReader. You use repeatitems: false property, which means that every item of input data has properties CountryName, StateName and so on. The default name of the id property (the rowid - the id of
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to open new tab on ASP C# and focus stay on current page then current page redirect to another page on click button?


Tag : chash , By : Epora75
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Yes, you should remove Response.Redirect(url);, otherwise your code above it is lost. What browser are you using? It's not only you code that controls this behaviour. The browsers have settings for that too. For example, in Internet Explorer 11, go to Internet Options and click on the Tabs button on the general tab. Notice the setting Always switch to new tabs when they are created, if it is checked, then it will behave the way you described it. Clear it and see what happens.

how to keep current page in jqgrid on clicking edit button


Tag : jquery , By : Timbo
Date : March 29 2020, 07:55 AM
like below fixes the issue Your current implementation of editing opens just new HTML page. In the way you loss all information about the state of the grid. You should consider to use Ajax to communicate with the server. It's the way of the standard editing implemented in jqGrid.
Alternatively you can save the current page inside of localStorage of the web browser or in the cookie. To get the current page of the grid you can use $("#productvariationListGrid").jqgrid("getGridParam", "page"). In the code executed before the grid is created you should try to get the page number from the localStorage (or from the cookie). One can use page: oldPage option of jqGrid to create the grid and to load oldPage instead of the first page.

Open any url in popup and redirect current page in ASP.net without any button click on page load


Tag : chash , By : Xander
Date : March 29 2020, 07:55 AM
I hope this helps you . When someone opens my webpage I would like a popup to open, and then I would like the main page (not the popup) to redirect to another website. , You can use below code:
Common function for open PopUp window:
function PopupCenter(url, title, w, h) {
     var child;
     var timer;
     var guid;

    var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
    var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;

    width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
    height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

    var left = ((width / 2) - (w / 2)) + dualScreenLeft;
    var top = ((height / 2) - (h / 2)) + dualScreenTop;

    child = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);

    if (child.focus) {
        child.focus();
        parent.location.assign("http://blabla.com/");// Change parent Page location
    }
}
PopupCenter('http://www.google.com', 'Widow Title', '1000', '1000');
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","PopupCenter('http://www.google.com', 'Widow Title', '1000', '1000');",true);

It is possible to refresh/reload a jqgrid in another view/page after a button is click?


Tag : javascript , By : CM.
Date : March 29 2020, 07:55 AM
this will help Yes it is possible. I am not sure what server side language you are using but using web-sockets or signalR you can send a message to all open pages to refresh if data has been refreshed on server. You can also use polling to achieve that. Concept is this:
You update data from grid or anywhere on page 1 and that goes to server. Now you want to refresh pages that may contain this data or intend to show it. Polling : On all such pages you refresh the data from server if there is a change obtained from polling SignalR : You can use a hub to send a method to all clients to run a javascript code that checks for grid presence and then refresh it.

Asp.net MVC Redirect to another view from current view page using ajax call


Tag : javascript , By : Vijayant Singh
Date : March 29 2020, 07:55 AM
this one helps. In the success function of your ajax call use below for redireccting to other view:
window.location.href = "/controller/action?id=" + id;
Related Posts Related QUESTIONS :
  • All data in the db is lost when closing a express based node js server
  • How to convert javascript code for Angular
  • XPath select on child nodes
  • Idle event on mouse move - how to stop script permanently on mouse move
  • Why do I get logic is not defined in this code
  • When I enter a number in the input, the first function starts
  • ES6 imports and node_modules hell
  • How to get css selector of clicked-on element?
  • How to auto input MySQL data (input column 1 data to auto input column 2 data with same column) in php?
  • Appending to Datalist Via Javascript
  • Customizing Material-UI Components with Styled-Components
  • Populate elements with class name using Javascript
  • How to execute promises in batches (first resolving 10, then next 10 and so on)
  • Maximo JS automation script: "importPackage" is not defined
  • How to surround selected text inside textarea with <em> on key combination CTRL+i?
  • Your configured registry does not support audit requests ~ On npm audit
  • What's the Angular equivalent of Vue <slot/>?
  • Iconify icon not updating when "data-icon" set with setAttribute()
  • Javascript newbie stuck with XMLHttpRequest return data
  • How to add obj to to state in my example Redux React
  • Loading "grunt-karma.js" tasks...ERROR >> SyntaxError: Unexpected identifier
  • Why do I get log is not defined
  • get the multiple index of the same string
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Make web service not accessible by browser?
  • Select DOM elements within template
  • How to customize angular ui-grid row background color?
  • Binding data in two respective $scope in AngularJS, how?
  • react put some props after import class
  • Variable is distributed among same components
  • switch class in jQuery/JavaScript for active/inactive state
  • How To Track Outbound Clicks Using Javascript
  • How to get total seconds elapsed since the beginning of the month?
  • Protractor: Stale element reference at "browser.wait(EC.visibilityOf(confDial), FIFTY_SECONDS);"
  • Access to an array inside an object
  • Reseting an JavaScript Interval with different value?
  • Learning Angular for the first time - version 2 or 4?
  • Rendering RSS feed (XML) in React with jquery, why do object values parsed from the feed seem empty?
  • Node.js xml2js http.request tag matching
  • applying texture to custom plane geometry in Threejs
  • How do I pass an Event as a function parameter in HTML written inside JavaScript variable?
  • Interface of object parameter with default value and default property
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com