Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding postData to / changing URL in jqGrid #15

Open
ThaDafinser opened this issue Aug 28, 2017 · 0 comments
Open

Adding postData to / changing URL in jqGrid #15

ThaDafinser opened this issue Aug 28, 2017 · 0 comments

Comments

@ThaDafinser
Copy link
Contributor

From @webdevilopers on June 16, 2014 13:55

My grid starts on an URL that depends on a week GET param from an HTML5 element:
http://localhost:8000/timekeeping/overview?week=2010-W50

First I tried to add the week param to the postData:
The postData param is already implemented inside the layout:

    mtype : 'POST',
    postData: {
        <?php echo $parameterNames['columnsHidden']?>: function(){
            return $('#<?php echo $this->gridId.'_'.$parameterNames['columnsHidden']; ?>').val();
        },
        <?php echo $parameterNames['columnsGroupByLocal']?>: function(){
            return $('#<?php echo $this->gridId.'_'.$parameterNames['columnsGroupByLocal']; ?>').val();
        }
        <?php
        if(count($parametersHtml) > 0){
            echo ',';
        }
        echo implode(',', $parametersHtml);
        ?>,
    },

The imploded $parametersHtml can be found at the top:

$parametersHtml = array();
foreach($this->parameters as $name => $value){
    $parametersHtml []= $name.': \''.$value.'\'';
}

And then set the value on the grid:

        $grid->setParameters(array(
            'week' => (string) $weekParam,
                'week2' => '2014-W01',
            'foo' => 'bar',
            'foo2' => 'bar2'
        ));

Unfortunately the week param was not added to the POST request while the other params would. The problem seems to be that I already have a column named week too that is also used with groupingView.

I then tried to change the URL via:

        $url = $this->url()->fromRoute('timekeeping', array(
            'action' => 'overview',
            'week'   => $weekParam
        ));

$grid->setUrl($url);

But the grid seems to overwrite the URL at least inside the layout:

$url = $this->url(null, array(), array(), true);
if($this->overwriteUrl != ''){
    $url = $this->overwriteUrl;
}

In the end I came up with an individual layout template simply commenting out the mentioned section:

// $url = $this->url(null, array(), array(), true);
// if($this->overwriteUrl != ''){
//     $url = $this->overwriteUrl;
// }
$url = $this->url;

Though it did not end with the expected result because the URL now is completey empty:

var grid_defaultGrid = $('#defaultGrid').jqGrid({

    url: '',

Any ideas?

Copied from original issue: ThaDafinser/ZfcDatagrid#117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant