contributte / contributte/datagrid

Problem with payload state and creating an URL in JS

Open
#829 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T: Feature
Dominant language
PHP
Stars
296
Forks
215
PR merge metrics
No merged PRs in 30d

Description

Datagrid should use something different than state to create a URL in Javascript. The problem is that the state can mapped values. If I define filter in Nette Router, the state will contain these mapped values, not the ones which should be in the URL. In my case I'm converting id=123 into a object which is accessible in presenter as $this->id. The id is persistent. Nette Presenter will send the object, not the id (123). One option is to change the presenter to cenvert it back, but this is state, not url information.

Would it be good approach to send another payload from datagrid, which can be 'urlPrefix' and it will contain actual url, without datagrid component values. Datagrids JS will only add it's own parameters dependent on the action.

This is relevant only to the URL which is changed in the browser. It looks like everything is working until I refresh the page. In that case the persistent parameter which was filtered to object is lost.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Datagrid JavaScript that constructs browser URLs and the payload fields used for state and persistent parameters. Reproduce the issue by refreshing a page whose router filter maps an id to an object, then compare the URL before and after refresh. Done means the mapped persistent value remains usable after refresh without relying on serialized component state.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.