Implem / Implem.Pleasanter

Pleasanter is a no-code/low-code development platform that runs on .NET. You can quickly create business applications with simple operations.
https://pleasanter.org
GNU Affero General Public License v3.0
511 stars 81 forks source link

Javascriptを使用してチェックを入れたレコードが$p.selectedIdsで取得できない #500

Closed ryumtym closed 5 months ago

ryumtym commented 7 months ago

一覧画面を開いたときに特定のレコードにチェックを入れる以下の様なコードを用意して、チェック後に$p.selectedIdsでIDを取得しようとすると空の配列が返ってきます。

const records = [123, 456, 789];
records.forEach(elm => {
    $(`tr[data-id="${elm}"]`).find('input.grid-check').prop('checked', true);
})

console.log($p.selectedIds());

上記コード動作後にどこか1か所のチェックを付け直すと$p.selectedIdsが機能するため、現状はその作業も併せて行っていますが解決策はありますか?

nagamune-implem commented 7 months ago

Issueありがとうございます。

参考となるコードを貼り付けます。 なお、本コードは説明のためのコードです。実際に利用される場合は十分にテストを行ってお使い(参考にして)ください。 またバージョンアップで振る舞いが変わる場合がある事をご了承ください。

function my_function() {
    const records = [123, 456, 789];
    records.forEach(elm => {
        const c = $(`tr[data-id="${elm}"]`).find('.grid-check,.select');
        c.prop('checked', true);
        if (c.length) c.change();
    });
    console.log($p.selectedIds());
}

プリザンターでは内部に差分を保持しており効率的にデータ更新を行っています。 従って、表示データだけではなく、今回の場合は"c.change();"を呼ぶ事で表示に合わせた内部データの更新を行います。

また、プリザンターの一覧表示画面では表示分+αのレコードのみを受信している関係で、下スクロールすることで更に必要なレコードを取得しております。従いまして、関数呼び出し時に読み込まれていないIDに関してはチェックマークをつけることが出来ません。追加読み込みイベント後に更に設定を行うコードを記載してください。

不明点等ございましたらコメントを頂ければと思います。

ryumtym commented 7 months ago

回答ありがとうございます。 頂いたコードをもとに試しましたが配列は空でした。

またバージョンアップで振る舞いが変わる場合がある事をご了承ください。

1.34.40.0を現在使用していますが、これは関連しているでしょうか?

nagamune-implem commented 7 months ago

ご確認ありがとうございます。

1.34.40.0を現在使用していますが、これは関連しているでしょうか?

1.3.40.0でも問題ございません。

すこし見やすくコードを書き換えた物を添付いたします。 記録テーブルと期限付きテーブルの一覧画面で確認いたしました。

function my_function() {
  const records = [41,42,43,1]; // <= ここを実際にあるIDに変更して下さい。
  records.forEach(elm => {
    const c = $(`tr[data-id="${elm}"]`).find('.grid-check,.select');
    c.prop('checked', true);
    if (c.length) c.change();
  });
}
my_function();
console.log($p.selectedIds());
github-actions[bot] commented 5 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 5 months ago

This issue was closed because it has been stalled for 7 days with no activity.