从jqgrid中删除拖放的行(Remove dragged and dropped row from jqgrid)
我有两个jqgrids设置,可以从'master'拖动到'target'网格。 我放入“目标”网格的行不会保存到数据库中,而是具有生成的唯一ID(前缀为“new_”)。 我有一个自定义寻呼机按钮,删除选定的行。 对于已保存的行,事件将从数据库中删除该项并重新加载网格。 这很好用。 但是,当我想删除未保存到数据库的拖动行时,不会删除该行。
这是我的按钮功能:
onClickButton: function () { var deleteId = tgtGrid.getRowData(tgtGrid.getGridParam('selrow'))['ID']; if (!deleteId) { return false; } // remove an added row, not saved in DB if (deleteId.indexOf('new_') != -1) { tgtGrid.jqGrid('delRowData', deleteId); } else { // remove account saved in DB $.post( url, { id: deleteId }, function (responseData) { if (!responseData.success) { // error here } else { // success here tgtGrid.trigger('reloadGrid'); } }); } }
如果我设置按钮在保存的行
tgtGrid.jqGrid('delRowData', deleteId);
上使用'delRowData'tgtGrid.jqGrid('delRowData', deleteId);
它返回true并从网格中删除行(不是DB,如预期的那样)。如何删除掉落的行?
I have two jqgrids setup and can drag from 'master' to 'target' grids. The row I drop into the 'target' grid is not saved to the database and has a generated, unique ID (prefixed with "new_"). I have a custom pager button that deletes the selected row. For saved rows, the event deletes the item from the database and reloads the grid. This works fine. However when I want to remove a dragged row that is NOT saved to the DB the row is not removed.
Here is my button function:
onClickButton: function () { var deleteId = tgtGrid.getRowData(tgtGrid.getGridParam('selrow'))['ID']; if (!deleteId) { return false; } // remove an added row, not saved in DB if (deleteId.indexOf('new_') != -1) { tgtGrid.jqGrid('delRowData', deleteId); } else { // remove account saved in DB $.post( url, { id: deleteId }, function (responseData) { if (!responseData.success) { // error here } else { // success here tgtGrid.trigger('reloadGrid'); } }); } }
If I set up the button to use 'delRowData' on the saved row
tgtGrid.jqGrid('delRowData', deleteId);
it returns true and the row is removed from the grid (not the DB, as expected).How do I remove a dropped row?
原文:https://stackoverflow.com/questions/26638982
最满意答案
你有没有对jar文件的控制权? 如果您创建它未压缩,那可能会更快。 显然它会使jar文件更大,但...
还有一件事要检查 - 你如何提取文件? 例如,如果你逐字节地做,它将会非常缓慢。 使用这样的东西:
public static void copyStream(InputStream input, OutputStream output) throws IOException { // Reads up to 8K at a time. Try varying this. byte[] buffer = new byte[8192]; int read; while ((read = input.read(buffer)) != -1) { output.write(buffer, 0, read); } }
如果你已经这样做了,你能给我们提供更多的信息吗? “有点慢”有多慢? 比如说,如何使用jar实用程序来提取jar文件?
Do you have control over the jar file? If you create it uncompressed, that may make it faster. Obviously it'll make the jar file bigger though...
Another thing to check - how are you extracting the file? For instance, if you're doing it byte by byte it will be painfully slow. Use something like this:
public static void copyStream(InputStream input, OutputStream output) throws IOException { // Reads up to 8K at a time. Try varying this. byte[] buffer = new byte[8192]; int read; while ((read = input.read(buffer)) != -1) { output.write(buffer, 0, read); } }
If you're already doing this, could you give us more information? How slow is "somewhat slow"? How does it compare with, say, using the jar utility to extract the jar file?
相关问答
更多-
你有没有对jar文件的控制权? 如果您创建它未压缩,那可能会更快。 显然它会使jar文件更大,但... 还有一件事要检查 - 你如何提取文件? 例如,如果你逐字节地做,它将会非常缓慢。 使用这样的东西: public static void copyStream(InputStream input, OutputStream output) throws IOException { // Reads up to 8K at a time. Try varying this. byt ...
-
在jar之前提取文件路径(extract file path right before jar)[2022-11-04]
您可以使用 file.getParentFile() 请参阅File#getParentFile() You can use file.getParentFile() See File#getParentFile() -
将库提取和打包到jar文件中的区别(Difference between extracting and packaging libraries into a jar file)[2022-07-11]
如果要将jar放入生成的jar文件中,可以使用打包方法。 例如,如果您正在使用Apache库或其他第三方jar,则可能需要将这些jar保存在生成的jar中。 在这种情况下,请使用包装。 “将需要的库打包成一个jar文件”选项将org.eclipse.jdt.internal.jarinjarloader包的类放入生成的文件中,这个包就在生成的jar文件的根目录下。 由于Eclipse的jar加载器类,此选项还会根据大小创建一个较大的jar文件。 提取所需的库将导致通过遵循包命名约定将第三方库的类放入您的ja ... -
Android Studio安装停留在'common-io.jar'提取上(Android Studio Installation stuck on 'common-io.jar' extraction)[2023-06-18]
这个问题现在已经解决了。 解决方案只是下载更新的设置 The issue is now solved. The Solution is just download an updated setup -
从jar文件中提取目录(Extract directory from jar file)[2023-05-27]
这个帖子的答案可能会让人感觉如何/从哪里开始: 如何从JAR和zip存档中提取Java资源 简单地说,这是你正在寻找的java.util.jar 。 An answer from this thread might give a good feeling how/where to start: How to extract Java resources from JAR and zip archive Simply put, it's java.util.jar you're looking for. -
Java 7 NIO.2 API(java.nio.file)可以轻松实现此目的。 它可以将jar文件(实际上只是一个.zip文件)视为一个文件系统,并直接从中复制文件。 查看java.nio.file.Path和java.nio.file.Files的javadoc,然后根据这些类查找cookbook配方。 The Java 7 NIO.2 API (java.nio.file) can easily accomplish this. It can treat the jar file (which is ...
-
这是因为您在C:\Program Files\Java\jdk1.7.0_25\bin没有写权限。 尝试在其他文件夹中解压缩它或以管理员身份打开控制台。 It's because you don't have write permissions in C:\Program Files\Java\jdk1.7.0_25\bin. Try uncompressing it in a different folder or open a console as administrator.
-
这适合您的需求吗? public static void main(String[] args) { try { copyJarFromZip("G:\\Dateien\\Desktop\\Desktop.zip", "G:\\Dateien\\Desktop\\someJar.jar"); } catch (IOException ex) { ex.printStackTrace(); } } publ ...
-
罐子是一个罐子。 对于类加载器,如何使用或不使用着色,Maven,Ant等创建jar都没有任何区别......所以“jar文件中的访问文件”包含正确的答案。 A jar is a jar. For the classloader is doesn't make any difference how that jar is created, either with or without shading, by Maven, by Ant, etc... So the "Access file in jar f ...
-
所以你想不允许Servlet Spec临时目录做它的事情,但仍然使用Servlet Spec? 请参阅有关临时目录如何工作的先前答案 。 选项1 这是embedded-jetty,跳过WebAppContext (及其Servlet Spec强制行为)并通过Handler(如ServletContextHandler )配置所有内容。 您将失去“发现”组件的能力,并且没有字节码扫描,但您将处于最终控制状态,并且将在亚秒级时间内测量启动。 选项#2 如果这只是一个启动问题,则忽略临时目录问题,在部署之前运行s ...