Sherzod Posted January 21, 2022 Share Posted January 21, 2022 Используйте afterrender, или boxready события. Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 2 minutes ago, Sherzod said: Почему 50? без понятия, это было в примере выше. А вон в событии afterCreate указано 0 и тоже ошибка Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 2 minutes ago, Sherzod said: Используйте afterrender я ж написал - ошибка, см. выше Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 4 minutes ago, x11 said: я ж написал - ошибка, см. выше Вы используете afterCreate. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 11 minutes ago, Sherzod said: Используйте afterrender, или boxready события. Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 10 minutes ago, Sherzod said: Используйте afterrender да какая разница? всё равно: Uncaught TypeError: list.getSelectedNodes()[0].scrollIntoViewIfNeeded is not a function при старте приложения, в консоли браузера Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 1 minute ago, x11 said: да какая разница? Вообще-то есть разница. OK. Если не трудно, можете прикрепить тестовый случай!? Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 Just now, Sherzod said: можете прикрепить тестовый случай!? вот же он, выше, в вашем сообщении http://forums.unigui.com/index.php?/topic/17865-how-to-show-the-user-a-specific-line-of-tunilistbox/&tab=comments#comment-97483 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 3 minutes ago, x11 said: вот же он, выше, в вашем сообщении http://forums.unigui.com/index.php?/topic/17865-how-to-show-the-user-a-specific-line-of-tunilistbox/&tab=comments#comment-97483 OK. Простите, но тестовый случай же работает? В чем проблема? Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 нет, не работает, именно этот пример я скачал, скомпилировал, запустил, в браузере сразу же ошибка: Uncaught TypeError: list.getSelectedNodes()[0].scrollIntoViewIfNeeded is not a function Перемещал эте 2 строки: var list = sender.boundList; list.on('select', function(){list.getSelectedNodes()[0].scrollIntoViewIfNeeded()}); в события afterrender или в boxready - все равно при старте в браузере ошибка у меня uniGUI 1555, D 10.4.2, Firefox Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 FireFox? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 Да, увидел. На FF ошибка. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 На Хроме работает. Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 3 minutes ago, Sherzod said: В чем проблема? Проверьте в Firefox. В Chome ошибки нет. Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 Just now, Sherzod said: На Хроме работает. Только вот есть один нюанс. Мне не нужна прокрутка списка при старте окна. Как я написал выше, прокрутка нужна после добавления новой строки. И вот этот код не работает даже в Хроме. procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniListBox1 do if ItemIndex <> -1 then JSInterface.JSCallDefer('boundList.getSelectedNodes()[50].scrollIntoViewIfNeeded', [True], 100); end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 1 minute ago, x11 said: JSInterface.JSCallDefer('boundList.getSelectedNodes()[50].scrollIntoViewIfNeeded', [True], 100); Здесь, вместо [50], укажите ноль [0] Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 8 minutes ago, x11 said: Мне не нужна прокрутка списка при старте окна. function afterCreate(sender) { var list = sender.boundList; list.on('select', function() { if (list.getSelectedNodes()[0].scrollIntoViewIfNeeded) { list.getSelectedNodes()[0].scrollIntoViewIfNeeded() } else { list.getSelectedNodes()[0].scrollIntoView() } }); } Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 Just now, Sherzod said: Здесь, вместо [50], укажите ноль [0] Теперь ошибок нет, но и прокрутка не работает. Вот код: procedure TMainForm.UniButton1Click(Sender: TObject); begin UniListBox1.ItemIndex := 10; UniListBox1.JSInterface.JSCallDefer('boundList.getSelectedNodes()[0].scrollIntoViewIfNeeded', [True], 100); end; Картинка 1 - до нажатия на кнопку. Картинка 2 - после нажатия на кнопку. Как видите, ползунок вверх подпрыгнул, но запись осталась та же. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 Just now, x11 said: Картинка 1 - до нажатия на кнопку. Картинка 2 - после нажатия на кнопку. 1 minute ago, x11 said: Какая из них? Я не вижу второй картинки. Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 4 minutes ago, Sherzod said: Мне не нужна прокрутка списка при старте окна. НЕ нужна прокрутка нужна при добавлении новой записи Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 1 minute ago, Sherzod said: Я не вижу второй картинки. простите, вот втрая Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 3 minutes ago, x11 said: прокрутка нужна при добавлении новой записи Ok, я проанализирую. Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 Just now, Sherzod said: Ok, я проанализирую. Я убрал JS вообще из ClientEvent. И на кнопку повесил этот: procedure TMainForm.UniButton1Click(Sender: TObject); Var s: string; idx: integer; begin s := 'test9 new row 123'; UniListBox1.Items.Add(s); idx := UniListBox1.Items.IndexOf(s); UniListBox1.ItemIndex := idx; UniListBox1.JSInterface.JSCallDefer('boundList.getSelectedNodes()[0].scrollIntoViewIfNeeded', [True], 100); end; при этом я включил свойство UniListBox1.Sorted. Этот код работает в Хроме и в Опере, но НЕ работает в Firefox. Другие браузеры не проверял. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 21, 2022 Share Posted January 21, 2022 Просто попробуйте scrollIntoView вместо scrollIntoViewIfNeeded Quote Link to comment Share on other sites More sharing options...
x11 Posted January 21, 2022 Share Posted January 21, 2022 1 minute ago, Sherzod said: Просто попробуйте scrollIntoView теперь прокручивает к какой-то левой записи выбирает запись с текстом "test5", вместо 'test9 new row 123' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.